Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can't pass parameter and call function in the DLL
Message
From
17/02/1999 13:19:07
 
 
To
17/02/1999 08:54:30
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00182255
Message ID:
00188516
Views:
17
>hi Ed Rauh,
> Below is the function i want to call and parameter want to pass and return:
>(1)
>>G_ICCPresent(const WORD16 ChannelNb,Byte *Response)
>>Byte Response
>>G_ICCPrensent(0,&Response)
>

&Response is the address of the variable Response.

>The question is how to call it in VFP by use your CLSHEAP.prg ?
>What is &Response mean ? The declare is look like this?:
>>Declare G_ICCPresent In V100_32.DLL string ChannelNb, String @Response

It's misdeclared; try:

DECLARE G_ICCPresent IN V100_32.DLL SHORT ChannelNB, STRING @ Response

Response = SPACE(1)

G_ICCPresent(0, @Response)

> I want get the return value of Response.
>
If the function call uses your buffer, Response will contain the value after the call.

If the function allocates it's own memory and passes the address back, you'd declare the second parameter as INTEGER

DECLARE G_ICCPresent IN V100_32.DLL SHORT ChannelNB, INTEGER PtrResponse

PtrResponse = 0
G_ICCPresent(0, @PtrResponse)
Response = GetMem(nPtrResponse,1)

The value of nPtrResponse after the call contains the pointer to Response, which you'd retrieve with GetMem(nPtr,1). I suspect from coding style that it allocates a value and passes back a pointer, but I can't be sure.

I'm not in a position to figure out how to make all this work for you, believe it or not, I have a job, and I have work to do for it. You need to learn something about how the function works, and I'm afraid that's going to mean learning some C to figure this stuff out. Perhaps hiring a consultant would be in order here.

>(2)Below is another function :
>>G_ReaderVersion(const WORD16 ChannelNb, Byte *Response)
>>Byte sDataOut[20}
>>G_ReadVersion(0,sDataOut)
>I want to get the return value of sDataOut, how in Vfp use CLSHEAP.prg?
>The declare statement is look like this ?
>>Declare G_ReaderVersion In V100_32.DLL string ChannelNb, string @response
>

Again, it's misdeclared:

Declare G_ReaderVersion In V100_32.DLL SHORT ChannelNb, string @response

You could initialize a variable Response to a length of 20 bytes

Response = space(20)

and call the function

G_ReaderVersion(0,@response)

or if it allocates it's own space and passes back the pointer, you'd need to pattern after the second strategy above. You'll have to research this yourself.

Someone else with more free time will have to help you here; it sounds like you need someone who understands both the .DLL being used and the mechanism of WIndows memory management. I've suggested that you read Jeff Richter's Advanced Windows to gain some insight into how memory management works.

>(3)Another Function :
>>G_ExchangeApdu(APDU_COMM *ApduComm, APDU_RESP *ApduResp)
>>typedef struct Apdu APDU_COMM;
>>typedef struct Resp APDU_RESP;
>>APDU_COMM ApduComm
>>APDU_RESP ApduResp
>>BYTE Command[COMMAND_LEN];
>> WORD16 LengthIn;
>>BYTE ReturnVal;
>Below is value to pass:
>>ApduComm.Command[0]=0x00;
>>ApduComm.Command[1]=0xde;
>>ApduComm.COmmand[2]=0x08;
>>ApduComm.Command[3]=0x2c;
>>ApduComm.LengthIn=0x00;
>>ReturnVal=G-ExchangeApdu(&ApduComm,&ApduResp)
>How to cal it in VFP ?
>
>You said i have to use the Alloc() method in CLSHEAP.prg but i'm not clear about the Alloc() method. I'm sure that the DLL is Win32 API.
>Thank you very much.
>
>regard,
>chang
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
Next
Reply
Map
View

Click here to load this message in the networking platform