Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Pointers in VFP?
Message
From
04/10/2006 10:45:06
 
 
To
04/10/2006 06:44:09
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01158687
Message ID:
01159352
Views:
26
Hi Christian, I am getting a handle to a device set which seems to work fine. Once I have that handle, I need to step through the set and pass each item to setupdienumdeviceinterfaces(). Below is the code I am currently working with for trying to figure this out:
*--below is a valid guid which I can get a handle to
cguid = [{36FC9E60-C465-11CF-8056-444553540000}]
? cguid

*!*	DIGCF_ALLCLASSES 
*!*	Return a list of installed devices for all device setup classes or all device interface classes. 
*!*	DIGCF_DEVICEINTERFACE 
*!*	Return devices that support device interfaces for the specified device interface classes. 
*!*	DIGCF_DEFAULT 
*!*	Return only the device that is associated with the system default device interface, if one is set, for the specified device interface classes. 
*!*	DIGCF_PRESENT 
*!*	Return only devices that are currently present in a system. 
*!*	DIGCF_PROFILE 
*!*	Return only devices that are a part of the current hardware profile. 
#DEFINE ERROR_NO_MORE_ITEMS        259
#DEFINE ERROR_INVALID_PARAMETER     87
#DEFINE ERROR_INVALID_FLAGS       1004
#DEFINE ERROR_INSUFFICIENT_BUFFER  122
#DEFINE DIGCF_INTERFACEDEVICE       16           && 0x00000010
#DEFINE DIGCF_PRESENT                2           && 0x00000002
#define DIGCF_ALLCLASSES             4
*!*	#define DIGCF_DEFAULT           0x00000001  // only valid with DIGCF_DEVICEINTERFACE
*!*	#define DIGCF_PRESENT           0x00000002
*!*	#define DIGCF_ALLCLASSES        0x00000004
*!*	#define DIGCF_PROFILE           0x00000008
*!*	#define DIGCF_DEVICEINTERFACE   0x00000010

DECLARE SHORT StrToIntEx IN Shlwapi; 
	STRING pszString, INTEGER dwFlags, INTEGER @pllRet 

DECLARE INTEGER GetLastError IN kernel32

DECLARE INTEGER SetupDiGetClassDevs IN setupapi.dll ;
    STRING @cGuid, ;
    STRING Enumerator, ;
    INTEGER hwndParent, ;
    INTEGER nFlags
    
 nflags = 0   
 Enumerator = []
 hwndParent = 0
   
DECLARE INTEGER SetupDiEnumDeviceInterfaces IN setupapi;
	INTEGER DeviceInfoSet,;
	STRING @ DeviceInfoData,;
	STRING @ ByRefterfaceClassGuid,;
	INTEGER MemberIndex,;
	STRING @ DeviceInterfaceData
	
sizeof = REPLICATE(' ',2048)+CHR(0)
i = 1
nInfo = REPLICATE(' ',2048)+CHR(0)
PSP_DEVINFO_DATA = []
	
lnpointer = 0
DO WHILE .T.
	lnpointer =  SetupDiGetClassDevs(@cGuid,null,0,DIGCF_INTERFACEDEVICE)
	IF TYPE('lnpointer') = "N" .and. lnpointer > 0
		lldestroy = .t.
		? '        Handle to Device Set: '
		?? ALLTRIM(STR(lnpointer))
		DeviceInfoSet = lnpointer
		i = 1
                *--I have a handle to the device set (DeviceInfoSet)
		*--Now I need to step through the set and pass each item to the below function	

*!*			IF !SetupDiEnumDeviceInterfaces(DeviceInfoSet, @nInfo , @cGuid, 0, @sizeof)
*!*				IF GetLastError() = ERROR_NO_MORE_ITEMS
*!*					EXIT
*!*				ELSE
*!*					EXIT
*!*				ENDIF
*!*			ELSE
*!*				EXIT
*!*			ENDIF
			
	ELSE
		EXIT
	ENDIF
ENDDO
IF lldestroy
	*--Cleanup
	?'=================================================='
	?'Cleaning Up...'
	DECLARE INTEGER SetupDiDestroyDeviceInfoList IN setupapi;
	    INTEGER DeviceInfoSet
	llokay = SetupDiDestroyDeviceInfoList(lnpointer)
	?'        Releasing the handle - SetupDiDestroyDeviceInfoList Result: '
	?? llokay
	?'        Last Error: '
	?? GetLastError()
	
ENDIF
RETURN

FUNCTION hex2dec (lcHex)
#DEFINE STIF_SUPPORT_HEX           1 
LOCAL lnRet 
lnRet = 0 
IF StrToIntEx (lcHex, STIF_SUPPORT_HEX, @lnRet) = 1
	RETURN lnRet
ELSE
	RETURN 0
ENDIF

RETURN



*************************************************************************

//
// Device information structure (references a device instance
// that is a member of a device information set)
//
typedef struct _SP_DEVINFO_DATA {
    DWORD cbSize;
    GUID  ClassGuid;
    DWORD DevInst;    // DEVINST handle
    DWORD Reserved;
} SP_DEVINFO_DATA, *PSP_DEVINFO_DATA;

//
// Device interface information structure (references a device
// interface that is associated with the device information
// element that owns it).
//
typedef struct _SP_DEVICE_INTERFACE_DATA {
    DWORD cbSize;
    GUID  InterfaceClassGuid;
    DWORD Flags;
    DWORD Reserved;
} SP_DEVICE_INTERFACE_DATA, *PSP_DEVICE_INTERFACE_DATA;

//
// Flags for SP_DEVICE_INTERFACE_DATA.Flags field.
//
#define SPINT_ACTIVE  0x00000001
#define SPINT_DEFAULT 0x00000002
#define SPINT_REMOVED 0x00000004

//
>Hello Tracy,
>
>"how would you access the properties of the result if the result is a set?"
>
>i don't quite understand what you mean.
>Do you mean a function that returns a pointer to an array of C style strings?
>
>e.g.
>
>DECLARE INTEGER SomeFunc IN somedll.dll INTEGER @ nArraySize
>LOCAL lnSize
>lnSize = 0
>lnPointer = SomeFunc(@lnSize)
>FOR xj = 1 TO lnSize
> ? "Item", xj, SYS(2600,lnPointer)
> lnPointer = lnPointer + 4 && + sizeof(char*)
>ENDFOR
>
>
>if this is not what you meant, you may point me to the API function that you wanna use so i can have a look at it and give you a more precise answer.
>
>Christian
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform