Subject |
Re: Computer serial number |
From |
Bernard Mouille <bernardmouille16@gmail.com> |
Date |
Sun, 21 Apr 2024 01:14:41 -0400 |
Newsgroups |
dbase.getting-started |
Attachment(s) |
Test.txt |
Look my little WMI tool.
Regards,
Bernard.
Rachhpal Gill Wrote:
> How I can store serial number in memory variable?
> Following command is used
>
> C:\\>wmic bios get serialnumber
>
>
| /* WMI - For Win32 and CIM class.
This code is a basic sample.
*/
//local f
local oLocator
local Items
local oWMI
local i
local j
local classe // ( in french because class is dBase reserved word ).
// Class name.
//classe = "CIM_DesktopMonitor"
//classe = "CIM_DMA"
//classe = "CIM_Memory"
//classe = "CIM_MemoryCapacity"
//classe = "CIM_MemoryCheck"
//classe = "CIM_MemoryMappedIO"
//classe = "CIM_MemoryOnCard"
//classe = "CIM_NonVolatileStorage"
//classe = "CIM_OSVersionCheck"
//classe = "CIM_PhysicalMedia"
//classe = "CIM_PhysicalMemory"
//classe = "CIM_Setting"
//classe = "CIM_Thread"
//classe = "CIM_USBDevice"
//classe = "Win32_BaseBoard" // Infos carte mère.
classe = "Win32_BIOS"
//classe = "Win32_CIMLogicalDeviceCIMDataFile"
//classe = "Win32_DesktopMonitor"
//classe = "Win32_DiskDrive"
//classe = "Win32_DMAChannel"
//classe = "Win32_NetworkClient"
//classe = "Win32_NetworkConnection"
//classe = "Win32_NetworkLoginProfile"
//classe = "Win32_NetworkProtocol"
//classe = "Win32_OperatingSystem"
//classe = "Win32_physicalmedia"
//classe = "Win32_Printer"
//classe = "Win32_Process"
//classe = "Win32_Processor"
//classe = "Win32_Service"
bd_SetAlte( "_Result.txt" )
? "Infos for class : " + classe
?
oLocator = new OleAutoClient( "WbemScripting.SWbemLocator" )
oWMI = oLocator.ConnectServer( ".", "root\cimv2" )
Items = oWMI.ExecQuery( 'Select * from ' + classe )
? "Items count : " + ltrim( str( Items.count, 9, 0 ) )
?
if Items.count < 1
? "No item for class : " + classe
else
for i = 0 to Items.count - 1
? replicate( "-", 99 ) + " " + ltrim( str( i + 1, 9, 0 ) )
for j = 0 to Items[ i ].Properties_.Count - 1
? BD_ValType( Items[ i ].Properties_[ j ].Value ) at 0
?? Items[ i ].Properties_[ j ].Name at 3
?? Items[ i ].Properties_[ j ].Value at 30
endfor
? "Methods :", Items[ i ].Methods_.Count
for j =0 to Items[ i ].Methods_.Count - 1
? Items[ i ].Methods_[ j ].Name + "()"
endfor
endfor
endif
oLocator := null
Items := null
oWMI := null
bd_setalte()
bd_ShellExecute( "_Result.txt" )
return
// Erase a file.
// Last change : 2018-12-28
function bd_fErase( cFile, nTimeMax )
local nTime
local lSuccess
if argcount() < 3
nTimeMax = 5
endif
nTime = 0
lSuccess = true
do while nTime <= nTimeMax * 10
try
if new file().exists( cFile )
new file().delete( cFile )
endif
exit
catch ( Exception e )
lSuccess := false
sleep 0.1
nTime++
endtry
enddo
return lSuccess
// Choose and change SET ALTERNATE.
// Last change : 2019-01-07
function bd_SetAlte( cFile )
local cRetutn
private MACRO_File
if argcount() < 1
?
set alternate off
set alternate to
cReturn = cFile
else
MACRO_File = ( cFile )
if at( "\", MACRO_File ) == 0
MACRO_File := set( "directory" ) + "\" + MACRO_File
endif
bd_ferase( MACRO_File )
set alternate to &MACRO_File
set alternate on
cReturn = MACRO_File
MACRO_File := null
endif
release MACRO_File
return cReturn
// Execute a command with options.
// Last change : 2018-12-21
function bd_ShellExecute( xHorCom, cOp, cFile, cPara, cDir, nShow )
if type( "ShellExecuteA" ) <> "FP"
extern CHANDLE ShellExecuteA( CHANDLE, CSTRING, CSTRING, CSTRING, CSTRING, CINT ) Shell32.dll
endif
if argcount() == 1
ShellExecuteA( null, "open", xHorCom, null, null, 1 )
else
ShellExecuteA( xHorCom, cOp, cFile, cPara, cDir, nShow )
endif
return
// Return the type of a value or a variable.
// Last change : 2018-11-16
function bd_ValType( xData )
local cReturn
private PRIVATE_xData
PRIVATE_xData = xData
cReturn = type( "PRIVATE_xData" )
PRIVATE_xData := null
release PRIVATE_xData
return cReturn
|
|