Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Passing Parameters DWORD PTR using API conundrum
Message
 
To
10/10/2006 12:52:46
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
01160919
Message ID:
01160942
Views:
13
This message has been marked as the solution to the initial question of the thread.
Probably :
IF SetupDiEnumDeviceInterfaces( ;
	m.lnDeviceInfoSet, ;
	@m.lcDeviceInfoData, ;
	@m.lcClassGuid, ;
	m.lnx,;
	@m.lcDeviceInterfaceData)  = 0
>OK, I seem to be having a Friday afternoon on a Tuesday. The problem code is actually in red below. Given SetupDiEnumDeviceInterfaces is called as:
>
>DECLARE INTEGER SetupDiEnumDeviceInterfaces IN setupapi;
>	INTEGER DeviceInfoSet,;
>	STRING @ DeviceInfoData,;
>	STRING @ ByRefterfaceClassGuid,;
>	INTEGER MemberIndex,;
>	STRING @ DeviceInterfaceData
>
>and the parameters are:
>
>DeviceInfoSet
>[in] Handle to a device information set containing the devices for which to return interface information. This handle is typically returned by the SetupDiGetClassDevs or SetupDiGetClassDevsEx function.
>
>DeviceInfoData
>[in] Pointer to an SP_DEVINFO_DATA structure that constrains the search for interfaces to those of just one device in the device information set. This parameter is optional.
>
>InterfaceClassGuid
>[in] Pointer to a GUID that specifies the device interface class for the requested interface.
>
>MemberIndex
>[in] Zero-based index to the list of interfaces in the device information set. You should first call this function with the MemberIndex parameter set to zero to obtain the first interface. Then, repeatedly increment MemberIndex and retrieve an interface until this function fails and GetLastError returns ERROR_NO_MORE_ITEMS.
>
>If the DeviceInfoData parameter specifies a particular device, MemberIndex applies only to the interfaces exposed by that device.
>
>DeviceInterfaceData
>[out] Pointer to an SP_DEVICE_INTERFACE_DATA structure that receives information for the device interface. You must set the cbSize member to sizeof(SP_DEVICE_INTERFACE_DATA) before calling this function.
>
>and:
>
>TYPE SP_DEVICE_INTERFACE_DATA

> cbSize AS DWORD
> InterfaceClassGuid AS GUIDAPI
> Flags AS DWORD PTR Reserved
>
>isn't the below correct:
>
>
>*--The GUID_DEVCLASS_DISKDRIVE is correct it works with other setupapi calls
>#Define GUID_DEVCLASS_DISKDRIVE ;
>	Chr(0x67) + Chr(0xE9) + Chr(0x36) + Chr(0x4D) + ;
>	Chr(0x25) + Chr(0xE3) + ;
>	Chr(0xCE) + Chr(0x11) + ;
>	Chr(0xBF) + Chr(0xC1) + Chr(0x08) + Chr(0x00) + Chr(0x2B) + Chr(0xE1) + Chr(0x03) + Chr(0x18)
>m.lcClassGuid = GUID_DEVCLASS_DISKDRIVE
>*--The below value is correct - it is returned from SetupDiGetClassDevs
>m.lnDeviceInfoSet = 432974329 && this value actually returned from SetupDiGetClassDevs and is valid
>*--The below should be correct - it works with SetupDiEnumDeviceInfo and returns correctly
>m.lcDeviceInfoData = Padr(BinToC(28, [4RS]), 4, Chr(0)) + Replicate(Chr(0), 24)
>*--Start with 1st device - I know it works too using SetupDiEnumDeviceInfo
>m.lnx = 0
>*--Given the the definition I included above for SP_DEVICE_INTERFACE_DATA below should be ok
>m.lcDeviceInterfaceData = long2str(32)+Replicate(CHR(0),28)
>*--Assuming the line above may be wrong, I also tried:
>*m.lcDeviceInterfaceData = CHR(32)+CHR(0)+CHR(0)+CHR(0) &&dword only
>*--to no avail as well as:
>*m.lcDeviceInterfaceData = num2dword(32)+num2dword(0)+num2dword(0)+;
>*num2dword(0)+num2dword(0)
>
>
>However the below code returns data type mismatch:
>
>IF SetupDiEnumDeviceInterfaces( ;
>	m.lnDeviceInfoSet, ;
>	@m.lcDeviceInfoData, ;
>	@m.lcClassGuid, ;
>	m.lnx,;
>	@m.lcDeviceInterfaceData)
>					
>
>
>Any ideas anyone?
>TIA,
>Tracy
>
>
>
>
>
>*************************************************************
>FUNCTION long2str
>*************************************************************
>   * passed : 32-bit non-negative numeric value (m.longval)
>   * returns : ascii character representation of passed
>   *    value in low-high format (m.retstr)
>   * example :
>   *   m.long = 999999
>   *   m.longstr = long2str(m.long)
>   PARAMETERS m.longval
>
>   PRIVATE i, m.retstr
>
>   m.retstr = ""
>   FOR i = 24 TO 0 STEP -8
>      m.retstr = CHR(INT(m.longval/(2^i))) + m.retstr
>      m.longval = MOD(m.longval, (2^i))
>   NEXT
>   RETURN m.retstr
>
>
>*************************************************************
>FUNCTION str2long
>*************************************************************
>* passed:  4-byte character string (m.longstr) in low-high ASCII format
>* returns:  long integer value
>* example:
>*	m.longstr = "1111"
>*	m.longval = str2long(m.longstr)
>
>PARAMETERS m.longstr
>
>PRIVATE i, m.retval
>
>m.retval = 0
>FOR i = 0 TO 24 STEP 8
>   m.retval = m.retval + (ASC(m.longstr) * (2^i))
>   m.longstr = RIGHT(m.longstr, LEN(m.longstr) - 1)
>NEXT
>RETURN m.retval
>
>*************************************************************
>FUNCTION  num2dword (lnValue)
>*************************************************************
>#DEFINE m0       256
>#DEFINE m1     65536
>#DEFINE m2  16777216
>	LOCAL b0, b1, b2, b3
>	b3 = Int(lnValue/m2)
>	b2 = Int((lnValue - b3 * m2)/m1)
>	b1 = Int((lnValue - b3*m2 - b2*m1)/m0)
>	b0 = Mod(lnValue, m0)
>RETURN Chr(b0)+Chr(b1)+Chr(b2)+Chr(b3)
>
>*************************************************************
>FUNCTION  num2word (lnValue)
>*************************************************************
>RETURN Chr(Mod(m.lnValue,256)) + Chr(Int(m.lnValue/256))
>
>
Previous
Reply
Map
View

Click here to load this message in the networking platform