BBC BASIC for Windows
General >> General Board >> Yahoo forum robbed code.... http://bb4w.conforums.com/index.cgi?board=general&action=display&num=1436384062 Yahoo forum robbed code....
Post by Yshua on Jul 8th, 2015, 7:34pm
Dearest Richard:
My pc got stolen. Lost my beloved BBC programs. Boils down to the Yahoo forum messages, dated Sept. 18, 2010, how to check pc unique identifiers, such as cpu clock speed, which program I found, but Yahoo raided the program that checked (non text removed) revision number, family of pc, etc. Was searching for hours under API's and WMI without finding where they are under MSDN Library. Apologize for the inconvenience.
Yshua Re: Yahoo forum robbed code....
Post by rtr2 on Jul 8th, 2015, 8:02pm
Richard.
Re: Yahoo forum robbed code....
Post by DDRM on Jul 9th, 2015, 09:38am
Hi Yshua,
I'm sorry to hear about your PC. Do you mean you couldn't download the program from Yahoo? It worked OK for me just now, so it might be worth trying again.
Best wishes,
D
Re: Yahoo forum robbed code....
Post by Yshua on Jul 9th, 2015, 12:48pm
Dearest Richard and D:
Fantastic!!!!! Worked terrific the first time with the following code changes to cpuspeed.bbc:
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%
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 pc description"
PRINT "Pc description: " ; var.ldata% ; "."
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"
PRINT "Manufacturer = " ; var.ldata% ; "."
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% ; "."
PROCcleanup
Bravo! And with just one remaining question; How did we add the "&FFFF" default value into the field of some of the variables assigned above to prevent erroneous data? Is there a reference in the BBC help file to explain?