Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Guide me please for HWInfo.ocx
Message
 
À
04/08/2005 14:32:42
Reza Meamar
Homa Programming Group
Shiraz, Iran
Information générale
Forum:
Visual FoxPro
Catégorie:
Contrôles ActiveX en VFP
Versions des environnements
Visual FoxPro:
VFP 7 SP1
Database:
Visual FoxPro
Divers
Thread ID:
01038424
Message ID:
01038670
Vues:
18
Reza,

I just copied all the files to a new folder (c:\fox\testing\hwinfo), then I opened the command window and registered the OCX
c:
cd \fox\testing\hwinfo
regsvr32 hwinfo.ocx
exit
Then I put the control in a form, and I got the info allright, alternatevily, if you have windows XP or 2003, you can use WMI with the following code:
? getLocalHDSerial(0)  && Serial of the first HD, similar to HardDisk1SerialNumber in the HWInfo control

function getLocalHDSerial(tnDevice)

local loLocator, lcUser, lcPassword, lcDomain, loNetWork, lnDevice
local loDrives, loDrive, lnCurrDevice, lcSerial


lnDevice			= Iif(Vartype(tnDevice) = 'N', tnDevice, 0)
lcSerial			= 'Unknown'

try
	loWBEMLocator		= createObject("wbemScripting.SwbemLocator")
	loWMIService		= loWBEMLocator.ConnectServer()
catch
	loWMIService		= null
endtry

if not Isnull(loWMIService)
	loDrives			= loWMIService.ExecQuery('Select SerialNumber from Win32_PhysicalMedia')
	lnCurrDevice		= 0
	for each loDrive in loDrives
		if lnCurrDevice	= lnDevice
			lcSerial		= loDrive.SerialNumber
			exit
		endif
		lnCurrDevice	= lnCurrDevice + 1
	endfor
endif
return Alltrim(lcSerial)
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform