关于存入,读取资源的问题(200分)

  • 主题发起人 绝对新手
  • 开始时间

绝对新手

Unregistered / Unconfirmed
GUEST, unregistred user!
资源存入的部分:<br>声明<br>&nbsp; hHand, hRes : THandle;<br>&nbsp; F:File;<br>&nbsp; size:integer;<br>&nbsp; PB: PByte;<br>代码<br>&nbsp; &nbsp; &nbsp; &nbsp; AssignFile(F,ExtractFilePath(ParamStr(0))+ 'TempDll.dll');<br>&nbsp; &nbsp; &nbsp; &nbsp; Reset(F,1);<br>&nbsp; &nbsp; &nbsp; &nbsp; Size:=FileSize(F);<br>&nbsp; &nbsp; &nbsp; &nbsp; GetMem(PB,Size);<br>&nbsp; &nbsp; &nbsp; &nbsp; BlockRead(F,PB^,5);<br>&nbsp; &nbsp; &nbsp; &nbsp; CloseFile(F);<br>&nbsp; &nbsp; &nbsp; &nbsp; hHand:= BeginUpdateResource(PCHar(ExtractFilePath(ParamStr(0))+ 'TempLoader.exe'),False);<br>&nbsp; &nbsp; &nbsp; &nbsp; if hHand = 0 then<br>&nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ShowMessage('没有找到Loader文件');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit;<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; UpdateResource(hHand,RT_RCDATA,'MainDll',1033,PB,Size);<br>&nbsp; &nbsp; &nbsp; &nbsp; EndUpdateResource(hHand,False);<br>&nbsp; &nbsp; &nbsp; &nbsp; FreeMem(PB);<br><br>读取的部分<br>声明<br>&nbsp; Shand, Res: THandle;<br>代码<br>&nbsp; SHand:=FindResource(hInstance,'MainDll',RT_RCDATA);<br>&nbsp; Res:=LoadResource(hInstance,SHand);<br>&nbsp; if Res = 0 then MessageBox(0,'没有找到资源','',0);<br>&nbsp; if Res &gt; 32 then<br>&nbsp; begin<br>&nbsp; &nbsp; Result:= LockResource(Res);<br>&nbsp; end;<br><br>为什么总是‘没有找到资源’;<br>用ResHacker可以看到文件中已有MainDll这个资源,但就是无法正确读出。
 
存入部分是把一个DLL文件加入到资源中命名为MainDll 类型是RT_RCDATA<br>读出部分是把这个DLL资源读出为一个PByte,后续是释放到文件夹中。<br>但是读出的时候总是找不到资源。
 
帮你顶上去
 
代码没问题,有可能是在.rc文件里你把资源名与资源类型名颠倒了。
 
自己解决了。<br>资源名必须大写,不大写就找不到资源。<br>放分了。
 
放分我来接...<br>快点分啊...
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
579
import
I
顶部