Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can't pass parameter and call function in the DLL
Message
De
14/02/1999 08:48:38
 
 
À
14/02/1999 07:35:09
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00182255
Message ID:
00187498
Vues:
26
>Hi Ed Rauh, Paul:
> I have another problem !!!
>>struct Session
>>{
>> WORD8 CardType;
>> WORD8 ResetLen;
>> BYTE ResetChar[RESET_LEN_MAX];
>> WORD8 HistLen;
>> WORD8 HistOffset;
>> WORD8 Dummy;
>> WORD32 ApduLenMax;
>>};
>
>>struct Apdu
>>{
>> BYTE Command[COMMAND_LEN];
>> WORD16 LengthIn;
>> BYTE *DataIn;
>> WORD32 LengthExpected;
>>};
>
>>struct Resp
>>{
>> WORD32 LengthOut;
>> BYTE *DataOut;
>> WORD16 Status;
>>};
>typedef struct Session SESSION_PARAM;
>typedef struct Apdu APDU_COMM;
>typedef struct Resp APDU_RESP;
>
>Above is another data structure of the functions.
>How to pass the parameters to the function ?
>Below is one of function call
>1)G_ExchangeApdu(const BYTE ChannelNb,APDU_COMM *ApduComm,
> APDU_RESP far *ApduResp);

DECLARE G_ExchangeApdu IN name of .DLL STRING, STRING @, STRING @

You'll have to use something like CLSHEAP or Paul's POINTERS class to construct the DataIn and DataOut buffers, and convert the pointers to the buffers into 4 byte character representations (in Win32 environments, pointers are 32 bit linear addresses, represented by DWORDs) using something like NumToDWORD to put them into your structures. And you're going to have to learn how to construct things in buffers using POINTERS or CLSHEAP; if you don't learn how structures and pointers work, you'll never be able to do this stuff yourself.

I suspect that you won't be able to use this function using DECLARE...DLL; the far * implies that this is a Win16 .DLL rather than a Win32 .DLL. You may be able to use the RegFn() interface in FoxTools to access it; I'm far from being an expert on FoxTools, but there's a great FAQ on it here on UT which you can download and read. And if it is Win16, the pointers to DataIn and DataOut might not be represented as simple DWORDs, since Win16 addresses are constructed differently (the Win16 environment is segmented; read Jeff Richter's Advanced Windows chapters 4-6; Charles Petzold has also written excellent books on programming in both the Win16 and Win32 environments.)

>
>2)How to convert the data type of BYTE in C ?
>

A BYTE is equivalent to CHR(Number). It's the same as a WORD8. A BYTE...[] is an array of bytes; a string of known length. A BYTE * is a pointer to an array of bytes; you'd have to allocate a buffer to be treated as an array of characters using something like CLSHEAP's Alloc() method, and convert the address that you're pointing a DWORD using NumToDWORD in CLSHEAP. I'm sure that Paul's POINTERS class has equivalent methods for dealing with these things.

Good luck!

Ed
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform