Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VB Call to API vs VFP
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00255827
Message ID:
00256180
Views:
21
>>Hi I need to convert some VB Call to An API Function into VFP, The VB Call IS:
>>
>>Public Type LStatus
>> DStatus As Integer
>> DCode As Integer
>> PStatus As Byte
>>End Type
>>
>>Private Declare Function GETStatus Lib "SomeDLL.dll" ( _
>> ByVal device As Integer, ByRef status As LStatus, _
>> ByRef devStatus As Byte, ByVal mode As Byte) As Byte
>>
>>My biggest problems are the Variables type BYTE, how do they convert to VFP and also the Structure LSTATUS
>>
>>My Conversion is the following:
>>
>>DECLARE INTEGER GetStatus IN SOMEDLL ;
>> INTEGER nDevice , STRING @STATUS, ;
>> INTEGER @devStatus, INTEGER mode
>>
>>It does not work properly and dont return anything in the Status Variable, The VB Call works fine.
>>

The variable passed in the invocation for status must be pre-initialized to a string value at least as long as the structure you've declared (in this case 9 bytes long, each integer is 4 consecutive bytes, and the trailing byte is a single character long. in addition, in order to get the modified value back from invoking the function, you need to pass the variables by reference in the invocation, ie:

nDevice = some numeric value
cString = SPACE(9)
nDeviceStatus = 0
nMode = some numeric value

nSomeVar = GetStatus(nDevice,@cString,@nDeviceStatus,nMode)


>>Anyone help will be greatly appriciated.
>>
>>Thanks
>
>Hi Stephane,
>
>Try using STRING to replace the BYTE type. For example, the status structure would be a character string nine characters long. Initialize the remaining references of BYTE to SPACE(1) (lcdevStatus = SPACE(1). The rest of the declaration looks ok. One thing I did note is that the declaration of the function in the DLL must match (in terms of case) that which is contained in the DLL.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform