Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Record structure in VFP
Message
De
08/07/2005 14:12:25
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
01030631
Message ID:
01030644
Vues:
14
Take a look at at:
How to pass struct to API? Thread #863805 Message #863805



>I have big problem. I must handle a few of record structure in WinApi function.
>Simple example:
>
 conctx_t = record
>	  sys_name: array [0..63] of Char;
>  	usr_name: array [0..23] of Char;
>	  jed_addr: array [0..15] of Char;
>  	jed_type: array [0..7] of Char;
>	  jed_opis: array [0..63] of Char;
>   	usr_opis: array [0..63] of Char;
>  end;
>Call of function:
int TLI_getCtx ( int handle, conctx_t* ctx )
>Size of struct = 252 (SizeOfFunction w Delphi get the required size of this structure)
>
>I try something like this (but this don't work :( )
>
FUNCTION  getStruc
>LPARAMETERS tnHandle
>DECLARE INTEGER HeapCreate IN Win32API;
>	INTEGER dwOptions, INTEGER dwInitialSize,;
>	INTEGER dwMaxSize
>DECLARE INTEGER HeapAlloc IN Win32API;
>	INTEGER hHeap, INTEGER dwFlags, INTEGER dwBytes
>DECLARE lstrcpy IN Win32API;
>	STRING @lpstring1, INTEGER lpstring2
>DECLARE INTEGER HeapFree IN Win32API;
>	INTEGER hHeap, INTEGER dwFlags, INTEGER lpMem
>DECLARE HeapDestroy IN Win32API;
>	INTEGER hHeap
>	
>DECLARE INTEGER TLI_getCtx IN TL_ILIB.DLL;
>	Integer @handle,;
>	Integer @conctx_t
>	
>lnheaphandle = HeapCreate(0, 4096, 0)
>IF lnheaphandle # 0
>* save the required size of the structure
>	lnsize = 252
>* Get a pointer to an address
>	lnheap = HeapAlloc(lnheaphandle, 0, lnsize)
>* Get the information into the structure
>* in delphi is  TF_TLI_getCtx = function (handle: Integer; ctx: pconctx_t): Integer; stdcall;
>*  conctx_t = record
>*	  sys_name: array [0..63] of Char;
>*  	usr_name: array [0..23] of Char;
>*	  jed_addr: array [0..15] of Char;
>*  	jed_type: array [0..7] of Char;
>*	  jed_opis: array [0..63] of Char;
>*   	usr_opis: array [0..63] of Char;
>*  end;
>
>	TLI_getCtx(lnHandle,lnHeap)
>* Copy the structure to VFP memory
>* In order to get the pointer to the string
>	lcstruct = SYS(2600, lnheap, lnsize)
>	lnptr = INT(val(SUBSTR(lcstruct, 5, 4)))
>* Initialize the buffer to receive the Driver
>* to MAX_PATH
>	lcresult = SPACE(240)
>	= lstrcpy(@lcresult, lnptr)
>* Remove the trailing CHR(0)
>	lcresult = LEFT(lcresult, AT(CHR(0), lcresult) - 1)
>* Free the heap
>	= HeapFree(lnheaphandle, 0, lnheap)
>* Clean up by destorying the handle
>* to the heap
>	= HeapDestroy(lnheaphandle)
>ENDIF
>
>Please help me !!!!
>
>Andrzej Multan


Alex Feldstein, MCP, Microsoft MVP
VFP Tips: English - Spanish
Website - Blog - Photo Gallery


"Once again, we come to the Holiday Season, a deeply religious time that each of us observes, in his own way, by going to the mall of his choice." -- Dave Barry
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform