Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Enumerating and accessing USB devices
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MySQL
Application:
Desktop
Divers
Thread ID:
01612196
Message ID:
01612215
Vues:
118
J'aime (1)
>We have a software that accesses the diabetes glucose meters via a serial port.
>Now they are introducing a new meter that has a USB connection. The way to access the meters needs to be done enumerating the USB devices and recognizing the meter by its device ID.
>
>I looked around for code that does the enumeration, but nothing that can simply be used in a VFP application.
>
>I wonder if there is an API or another third party interface that I could use in VFP?

If it is just the device id that you need, maybe something like this can give you a starting point:
clear
loLocator			= CREATEOBJECT('WBEMScripting.SWBEMLocator')
loWMI				= loLocator.ConnectServer()
loDevices			= loWMI.ExecQuery('Select * from Win32_USBControllerDevice')

for each loDevice in loDevices
	try
		loDependent			= GETOBJECT("winmgmts:" + loDevice.Dependent)
		? loDependent.Status, 'DeviceID: ', loDependent.DeviceID, 'Description: ', loDependent.Description, loDependent.Name
	catch to loException
		? 'Exception: ', loException.Message
	endtry
endfor
"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