Home > Back-end >  Do you have understand PureBasic?
Do you have understand PureBasic?

Time:10-13

 
FileHandle=CreateFile_ (FileName $, $40000000 | $80000000, 3, 0, 3, 0, 0)

If FileHandle & gt; 0
;======read resource file header information
The FileSize=FileSize (FileName $)
ReadSize=$110
* MemoryID=AllocateMemory (ReadSize)
Paddess=SetFilePointer_ (FileHandle, 0, 0, 0). Access to a resource file starting address of a pointer
ReadFile_ (FileHandle, * MemoryID ReadSize, @ Paddess, 0). Loading resource file
;======
key resource file information_FileCount=PeekL (* MemoryID + $104); The number of files
Pos=PeekL (* MemoryID + $108); The original position of the file index
;======to load the content of the resource file index part
The FileSize=FileSize - Pos
(* * MemoryID=ReAllocateMemory MemoryID FileSize)
Paddess=SetFilePointer_ (FileHandle, Pos, 0, 0); Access to a resource file starting address of a pointer
MemoryID ReadFile_ (FileHandle, * and FileSize, @ Paddess, 0). Loading resource file
;======closed resource file
CloseHandle_ (FileHandle)


Excuse me, does this paragraph written in PureBasic code is converted to PASCAL this
 
Var
FileHandle: DWORD;
FileSize: DWORD;
ReadSize: DWORD;
MemoryID: Pointer;
Paddress: DWORD;
FileCount: DWORD;
Pos: DWORD;
The begin
If OpenDialog1. Execute then
The begin
FileHandle:=CreateFile (PChar (OpenDialog1 FileName),
$40000000 or $80000000,
3,
Nil,
3,
0,
0);
If FileHandle & gt; 0 then
The begin
The FileSize:=length (OpenDialog1. FileName);
ReadSize:=$110;
MemoryID:=AllocMem (ReadSize);
Paddress:=SetFilePointer (FileHandle,
0,
Nil,
0);
ReadFile (FileHandle,
MemoryID,
ReadSize,
Paddress,
0);
FileCount:=DWORD (MemoryID) + $104;
Pos:=DWORD (MemoryID) + $108;
FileSize:=FileSize - Pos;
ReAllocMem (MemoryID FileSize);
Paddress:=SetFilePointer (FileHandle, Pos, 0, 0);
ReadFile (FileHandle, MemoryID FileSize, Paddress, 0).
The CloseHandle (FileHandle);
The end;
The end;

According to the above code will appear memory read error, consult everybody,,

CodePudding user response:

Don't understand, lu had

CodePudding user response:

Note the use of Pointers and var parameter types

CodePudding user response:

Predecessors know baidu PureBasic data is too little,,

CodePudding user response:

Single-step tracking, encountered an error, modify the parameters of the var to add, delete or ^ @
  • Related