S
sunman
Unregistered / Unconfirmed
GUEST, unregistred user!
我想在程序运行时把本程序加载到一个内存地址里,下面的代码为什么不对啊??<br>请高手指点!!<br>var<br> hFile,hMemory:Cardinal;<br> OwnFileName:array[0..255]of char;<br> dwSize,NumberOfBytesReadWrittenword;<br> pMemoryointer;<br> a:longbool;<br>begin<br> // strpcopy(OwnFileName,Application.ExeName );<br> GetModuleFileName(hinstance,OwnFileName,256);<br> hFile:=CreateFile(OwnFileName,GENERIC_READ, FILE_SHARE_READ,<br> nil,OPEN_EXISTING, FILE_ATTRIBUTE_ARCHIVE,0);<br> dwSize:=GetFileSize(hFile,nil);<br> hMemory:=GlobalAlloc(GMEM_MOVEABLE or GMEM_ZEROINIT,dwSize);<br> pMemory:=GlobalLock(hMemory);<br> a:=ReadFile(hFile,pMemory,dwSize,NumberOfBytesReadWritten,nil);<br> //上句ReadFile总是返回False啊!!<br> CloseHandle(hFile);<br>end;<br>