does anyone know if it is possible to convert a Windows-filehandle to a Purebasic-filehandle?
I want to read a logfile, but as ReadFile can not read shared-read I want to use CreateFile_.
I found a structure which seems to be a PureBasic-filehandle (http://www.purebasic.fr/german/viewtopic.php?t=1256), but when populating it and then calling a PureBasic-function with that filehandler it always says "[ERROR] #File object not initialized." Any ideas?
Code: Select all
Structure API_FileHandle
FHandle.l
Buffer.l
BufferLen.l
ReadPos.l
DataInBuffer.l
readed.l
EndStructure
Define myhFile.API_FileHandle
logfile.s = "C:\log.log"
hFile = CreateFile_(@logfile, #GENERIC_READ, #FILE_SHARE_READ Or #FILE_SHARE_WRITE, 0, #OPEN_EXISTING, #FILE_ATTRIBUTE_NORMAL, 0)
If hFile=#INVALID_HANDLE_VALUE
Debug "CreateFile failed!"
End
EndIf
myhFile\FHandle = hFile
myhFile\BufferLen = 4*1024
myhFile\Buffer=AllocateMemory(myhFile\BufferLen)
myhFile\readed=1
hFile = @myhFile
CloseFile(hFile)
Sepp