I have been having trouble passing file handles into and
out of DLLs. I have tried several times to open a file thus:
AcquisitionFileName = "MyAcqFile.ACQ"
hAcquisitionFile = FREEFILE
OPEN AcquisitionFileName FOR BINARY AS #hAcquisitionFile BASE = 0
I then try to call a function in a DLL and pass the file
handle (hAcquisitionFile) as a parameter to the function and
use it as:
FUNCTION GetPacket(AcquisitionFile AS INTEGER, _
PktBuf AS PIUDataPktStruc) EXPORT AS LONG
...
GET #AcquisitionFile,,PktBuf
...
END FUNCTION
When I examine the contents of the PktBuf TYPE, I find all
zeros. I have found that if I open the file in the DLL all
goes swimmingly and the packet buffer is filled as expected.
I have looked at the Microsoft documentation in my VC++
compiler, Petzold, and checked the FAQ and PB for Windows
areas for hints about the problem to no avail.
Does anyone know what is happening here? It seems that you
must be able to pass a file handle. The only help I saw was
a C function that would translate a C file handle to an
operating system file handle. This is, of course, of no
help in PB.
------------------
out of DLLs. I have tried several times to open a file thus:
AcquisitionFileName = "MyAcqFile.ACQ"
hAcquisitionFile = FREEFILE
OPEN AcquisitionFileName FOR BINARY AS #hAcquisitionFile BASE = 0
I then try to call a function in a DLL and pass the file
handle (hAcquisitionFile) as a parameter to the function and
use it as:
FUNCTION GetPacket(AcquisitionFile AS INTEGER, _
PktBuf AS PIUDataPktStruc) EXPORT AS LONG
...
GET #AcquisitionFile,,PktBuf
...
END FUNCTION
When I examine the contents of the PktBuf TYPE, I find all
zeros. I have found that if I open the file in the DLL all
goes swimmingly and the packet buffer is filled as expected.
I have looked at the Microsoft documentation in my VC++
compiler, Petzold, and checked the FAQ and PB for Windows
areas for hints about the problem to no avail.
Does anyone know what is happening here? It seems that you
must be able to pass a file handle. The only help I saw was
a C function that would translate a C file handle to an
operating system file handle. This is, of course, of no
help in PB.
------------------
Comment