BBC BASIC for Windows
Programming >> Communication and Input/Output >> cpuspeed program expansion.... http://bb4w.conforums.com/index.cgi?board=communication&action=display&num=1437068722 cpuspeed program expansion....
Post by Yshua on Jul 16th, 2015, 5:45pm
Dear BBC BASIC forum people:
Have a program running successfully, an expansion of cpuspeed.com, as follows:
ON ERROR PROCcleanup : SYS "MessageBox", @hwnd%, REPORT$, 0, 48 : QUIT ON CLOSE PROCcleanup : QUIT
REM Get CPU speed using WMI:
SYS `CoCreateInstance`, CLSID_WbemLocator%, 0, CLSCTX_INPROC_SERVER, \ \ IID_IWbemLocator%, ^pLoc% TO hr% IF hr% THEN ERROR 100, "Could not create IWbemLocator interface" !(^IWbemLocator{}+4) = !pLoc%
SYS IWbemLocator.ConnectServer%, pLoc%, FNwide("root\cimv2"), \ \ 0, 0, 0, 0, 0, 0, ^pSvc% TO hr% IF hr% THEN ERROR 100, "Could not create IWbemServices interface" !(^IWbemServices{}+4) = !pSvc%
SYS `CoSetProxyBlanket`, pSvc%, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, 0, \ \ RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, 0, 0 TO hr% IF hr% THEN ERROR 100, "Could not set proxy blanket"
query$ = FNwide("SELECT * FROM Win32_Processor") lang$ = FNwide("WQL") SYS IWbemServices.ExecQuery%, pSvc%, lang$, query$, \ \ WBEM_FLAG_FORWARD_ONLY, 0, ^pEnum% TO hr% IF hr% THEN ERROR 100, "Could not query Win32_Processor enumerator" !(^IEnumWbemClassObject{}+4) = !pEnum%
SYS IEnumWbemClassObject.Next%, pEnum%, -1, 1, ^pCPU%, ^nret% TO hr% IF hr% THEN ERROR 100, "Could not enumerate Win32_Processor object" !(^IWbemClassObject{}+4) = !pCPU%
DIM var{vartype{l&,h&},reserved&(5),ldata%,hdata%} SYS IWbemClassObject.Get%, pCPU%, FNwide("CurrentClockSpeed"), 0, \ \ var{}, 0, 0 TO hr% IF hr% THEN ERROR 100, "Could not get processor clock speed"
DIM var{vartype{l&,h&},reserved&(5),ldata%,hdata%} SYS IWbemClassObject.Get%, pCPU%, FNwide("DataWidth"), 0, \ \ var{}, 0, 0 TO hr% IF hr% THEN ERROR 100, "Could not get data width"
PRINT "data width = " ; var.ldata% AND &FFFF
DIM var{vartype{l&,h&},reserved&(5),ldata%,hdata%} SYS IWbemClassObject.Get%, pCPU%, FNwide("Description"), 0, \ \ var{}, 0, 0 TO hr% IF hr% THEN ERROR 100, "Could not get processor description"
DIM var{vartype{l&,h&},reserved&(5),ldata%,hdata%} SYS IWbemClassObject.Get%, pCPU%, FNwide("Manufacturer"), 0, \ \ var{}, 0, 0 TO hr% IF hr% THEN ERROR 100, "Could not get Manufacturer"
DIM var{vartype{l&,h&},reserved&(5),ldata%,hdata%} SYS IWbemClassObject.Get%, pCPU%, FNwide("Revision"), 0, \ \ var{}, 0, 0 TO hr% IF hr% THEN ERROR 100, "Could not get revision"
PRINT "Revision number = " ; var.ldata% AND &FFFF ; "."
DIM var{vartype{l&,h&},reserved&(5),ldata%,hdata%} SYS IWbemClassObject.Get%, pCPU%, FNwide("InstallDate"), 0, \ \ var{}, 0, 0 TO hr% IF hr% THEN ERROR 100, "Could not get install date"
after the CPU Description attribute, this attribute simply repeats the CPU Description. Also is there a limit to how many attributes can be printed out in the program?
Thanks sooo much, Yshua Re: cpuspeed program expansion....
Post by rtr2 on Jul 16th, 2015, 9:14pm
Now when even just one more WMI attribute is added, such as... "InstallDate"... this attribute simply repeats the CPU Description.
It doesn't "repeat" the CPU Description, that string is simply left over from the previous operation. If you had checked the returned VARTYPE you would have seen that it is VT_NULL, which I suspect simply means that the InstallDate property is not available for the processor.
Quote:
Also is there a limit to how many attributes can be printed out in the program?