Using lp binary for DLL callback lpstr's
Keywords: using LP binary for Dll Callback LPstr's long pointers
Two basic things to keep in mind:
- When dealing with DLL calls use BinaryEODSet to set the endpoint of the binary buffer as in:
xx=BinaryALloc(1234) BinaryEODSet(xx,1234)
- You will have to route the array data via a Binary buffer. You will probably have to have an area to build the array, then it will have to point to the strings you also stuff in there. But more importantly (and the reason to supply us with the code dump) Binary Alloc DOES NOT return a valid pointer to the buffer in some cases. Use IntControl 42 to translate a binary buffer handle to a lpstr... IntControl(42 allows you to get the addresses of a binarybuffer for computations.
Not for tha faint-hearted.
e.g.
PFileName=BinaryAlloc(StrLen(FileName)) PFileNameAddr=IntControl(42,PFileName,0,0,0) BinaryPoke4(OpenArchiveData,ArcName2,PFileNameAddr)Example:
int PASCAL FreqAsk(HAPP hApp, char far* retbuf) Where: Is: hApp A non-zero application handle from prior DLL retbuf The pointer to the buffer to return the frequency code. Return codes: 0 Successful NONE Error occurred
ret=FreqAsk(hApp, szFreqBuf) ; Try..... hApp=returned from prior dll dllhandle=prior dll display(4,"Handle",dllhandle) display(4,"ApplHandle",hApp) hBin=BinaryAlloc(255) BinaryEodSet(hBin,255) iret=DllCall(dllhandle,word:"FreqAsk",word:hApp,lpbinary:hBin) retbuf=BinaryPeekStr(hBin,0,255) BinaryFree(hBin) display(4,"iret",iret) display(4,"retbuf",retbuf)
Article ID: W12871Filename: Using lp binary for DLL callback lpstrs.txt