freddyzhu:[
]<br>我在用updateresource添加修改exe文件的 rt_sting 时有些问题,你说你已经成功添加修改 rt_sting rt_rcdata ,<br>能将你的那一部分源码贴出来吗?<br><br>以下是你要的实例,仅供参考。<br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> procedure Button1Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br><br>Function MAKELANGID(p,s:Word) : Word;<br>begin<br> Result:=( ( s shl 10 ) or p );<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var <br>lpResLock
ointer; // pointer to resource data<br>hExe,hRes,hResLoad,hUpdateRes:THandle; // handle to existing .EXE file<br>Getresult:Boolean;<br>begin<br>// Load the .EXE file that contains the dialog box you want to copy. <br>hExe := LoadLibraryex(Pchar('hand.exe'),0,LOAD_LIBRARY_AS_DATAFILE);<br> <br>if (hExe =0 ) then Showmessage('Could not load exe.');<br><br> <br>// Locate the dialog box resource in the .EXE file. <br><br>hRes := FindResource(hExe, '#6', RT_DIALOG);<br> <br>if (hRes = 0 ) then Showmessage('Could not locate dialog box.');<br><br>// Load the dialog box into global memory. <br>hResLoad := LoadResource(hExe, hRes);<br><br>if (hResLoad =0 ) then Showmessage('Could not load dialog box.');<br><br> <br>// Lock the dialog box into global memory. <br>lpResLock := LockResource(hRes);<br> <br>if (lpResLock = Nil ) then Showmessage('Could not lock dialog box.');<br>{<br>Dynamic updating of the resources in portable executable (PE) files is not<br>supported on Windows 95 nor on Windows 95 OSR 2. The following functions<br>are not supported:<br>1:BeginUpdateResource<br>2:EndUpdateResource<br>3:UpdateResource<br>}<br><br>// Open the file to which you want to add the dialog box resource.<br><br>hUpdateRes := BeginUpdateResource('foot.exe', False);<br><br>if (hUpdateRes =0 ) then Showmessage('Could not open file for writing.');<br><br>// Add the dialog box resource to the update list.<br>Getresult := UpdateResource(hUpdateRes, // update resource handle<br> RT_DIALOG, // change dialog box resource<br> '#6', // dialog box name<br> MAKELANGID(LANG_NEUTRAL,<br> SUBLANG_NEUTRAL), // neutral language ID<br> lpResLock, // ptr to resource info<br> SizeofResource(hExe, hRes)); // size of resource info.<br><br>if (Getresult = False) then Showmessage('Could not add resource.');<br><br>// Write changes to FOOT.EXE and then close it.<br>if ( Not EndUpdateResource(hUpdateRes, False)) then Showmessage('Could not write changes to file.');<br><br>// Clean up. <br>if ( Not FreeLibrary(hExe)) then Showmessage('Could not free executable.');<br><br>end;<br><br><br>end.