下面就是我使用的代码大挪移的方法,<br>在调用原函数时,不需要恢复原函数的代码<br><br>type<br> T_ShellAbout = function (Wnd: HWND; szApp, szOtherStuff: PAnsiChar; Icon: HICON): Integer; stdcall;<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>var<br> mi: TModuleInfo;<br> hd: THandle;<br> lp: PChar;<br> tf: PChar;<br> ntf: T_ShellAbout;<br> s, s1: String;<br> bf: String;<br>begin<br> SetLength(bf, 1024);<br> s := 'Test_Text_A';<br> s1 := 'Info';<br> hd := GetModuleHandle('shell32.dll');<br> tf := GetProcAddress(hd, 'ShellAboutA');<br> @ntf := tf;<br> ShowMessage(Format('Original: %P', [@ntf]));<br> ntf(Handle, 'test', 'fad',<br> LoadIcon(HInstance, 'MAINICON'));<br> if GetModuleInformation(<br> GetCurrentProcess, hd, @mi, SizeOf(mi)) then<br> begin<br> Caption := Format('%P, %d', [mi.lpBaseOfDll, mi.SizeOfImage]);<br> lp := VirtualAlloc(nil, mi.SizeOfImage,<br> MEM_COMMIT, PAGE_EXECUTE_READWRITE);<br> if lp <> nil then<br> begin<br> CopyMemory(lp, mi.lpBaseOfDll, mi.SizeOfImage);<br> @ntf := tf - mi.lpBaseOfDll + lp;<br> ShowMessage(Format('TheCopy: %P', [@ntf]));<br> ntf(Handle, 'test', 'fad',<br> LoadIcon(HInstance, 'MAINICON'));<br> VirtualFree(lp, 0, MEM_RELEASE);<br> end;<br> end;<br>end;<br><br>procedure TForm1.Button3Click(Sender: TObject);<br>begin<br> //必须加上这一行,否则shell32.dll 不会被加载<br> ShellAbout(Handle, 'test', 'fad',<br> LoadIcon(HInstance, 'MAINICON'));<br>end;