{I don't know why CSDN hates such words like 'up' and 'gz'. I also could not understand know why CSDN does not allow its member reply one's question more three times continuously.}if (pos('up')=0) or (pos('gz')=0) then begin showmessage('Fuck CSDN's goddam rules!'); end;//Jan. 12th, the memorable day,cet6 is coming towards me,a delphi fun...
MessageBox(0,'Sorry,but the HTML tag could not be translated.'+#13#10#13#10+'Press "AnyKey" to continue.','Fatal Error!',mb_ok+mb_iconerror);
资源列出来了,再怎么办????我想试试删除资源,可是也失败,麻烦高手看看 function aaa(hModule:HModule; lpszType:PChar; lpszName:PChar; lParam:LongInt):Boolean; stdcall; var resname:string; hh,lhandle:Thandle; hresload:hrsrc; hhicon:hicon; lpResLock:^char; begin // if DWORD(ResName)<$10000 then // Form1.Memo1.Lines.add(inttostr(dword(lpszName))); // lhandle:=BeginUpdateResource(pchar('c:\notepad.exe'),false);hhicon:=findresource(hmodule,lpszname,rt_icon); hResLoad:= LoadResource(hmodule, hhicon); lpResLock:= LockResource(hResLoad);lhandle:=BeginUpdateResource(pchar('c:\notepad.exe'),false); UpdateResource(lhandle,rt_icon,lpszname,LANG_CHINESE ,nil, SizeofResource(lhandle,hhicon)); if endupdateresource(lhandle,false) then showmessage('ok'); Result:=True end;procedure TForm1.Button1Click(Sender: TObject); var hres:Thandle; begin hres:=LoadLibraryEx (PChar ('c:\notepad.exe'), 0,Load_Library_As_DataFile); EnumResourceNames(hres,RT_ICON,@aaa,0); freelibrary(hres); end;
谁测试并修改以下代码,我怎么也不能测试成功?? to thedream(梦幻使者): 解决了,别忘了告诉我!:) [email protected] MakeLangID(PrimaryLanguage,SubLanguage : word) : DWord; begin Result:=SubLanguage shl 10; Result:=Result or PrimaryLanguage; end; procedure change; var hResLoad:HRSRC; // handle to loaded resource hExe:THANDLE; // handle to existing .EXE file hRes:HRSRC; // handle/ptr. to res. info. in hExe hUpdateRes:THANDLE; // update resource handle lpResLock:^char; // pointer to resource data return:BOOL; begin hExe := LoadLibrary('D:\M.exe'); if hExe=0 then messagebox(0,'error open exe','error',0); hRes := FindResource(hExe, 'MAINICON', RT_ICON); if hRes=0 then messagebox(0,'can not find ico','error',0); hResLoad:= LoadResource(hExe, hRes); if hResLoad=0 then messagebox(0,'Load error','error',0); lpResLock:= LockResource(hResLoad); if lpReslock=nil then messagebox(0,'can not lock resource','error',0);
hUpdateRes:= BeginUpdateResource('d:\P.exe', FALSE); if hUpdateRes=0 then messagebox(0,'can not open file for write','error',0); return:= UpdateResource(hUpdateRes, // update resource handle RT_ICON, // change Icon resource 'MAINICON', // Icon name MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), // neutral language lpResLock, // ptr to resource info SizeofResource(hExe, hRes)); // size of resource info. if return=false then messagebox(0,'can not add res','error',0); if (not EndUpdateResource(hUpdateRes, FALSE)) then messagebox(0,'can not make change','error',0); if (not FreeLibrary(hExe)) then messagebox(0,'can not free exe','error',0); end;
BOOL UpdateResource(
HANDLE hUpdate, // 用BeginUpdateResource获得的Handle
LPCTSTR lpType, // 资源类型名称(例如 RT_ICON, RT_ANIICON, 等)
LPCTSTR lpName, // 需要修改的资源的名称
WORD wLanguage, // 资源的语言类型, 可以使用MAKELANGID构造
LPVOID lpData, // 存放资源的二进制数据的地址
DWORD cbData // 用字节描述的数据的长度
); 还需要参考
BeginUpdateResource,
EndUpdateResource,
LoadIcon,
LoadString,
LockResource,
MAKEINTRESOURCE,
MAKELANGID,
SizeofResource
就是不知道用什么方法了,高手指点一下就快一些嘛,
to wwwwwwww(我我)
不是你说得这样,我的exe文件是做好了,没有源代码
我知道这些,试过了,我做不对,搞点代码给我了
在应用程序的编写中,组合框(ComboBox)、列表框(ListBox)、等常见的部件,通常不仅要用于显示文字,而且还要显示其与文字相关的图标。在一般的Windows应用程序中,这些图标的显示都要随列出的显示文本的变化而变化,例如在组合框中列出当前目录下的所有文件时,在组合框左边就显示与文件名相关联的图标,这就是所谓的动态图标。在Delphi中使用动态图标的步骤如下:一、图标的获取要使用动态图标,首先要解决的是如何获得显示文本和与其相关联的图标句柄。该图标通过文件关联由系统注册表决定,并且在Windows编程中同一文件(或子目录,或文件夹)在桌面上也可能有两种显示结果,这就是DOS文件名与显示名(Display Name)。如果我们的应用程序不需要有像Windows资源浏览器那样的效果,则可以使用FindFirst()和FindNext()二个函数以及FindClose()过程来获得DOS文件名,否则我们就应当使用WindowsAPI来获得显示名。在获得文件名的同时可通过使用ShellAPI.pas中的SHGetFileInfo()函数来获得其图标句柄HICON,说明如下:function SHGetFileInfo(pszPath: PAnsiChar; dwFileAttributes: DWORD;var psfi: TSHFileInfo; cbFileInfouFlags: UINT): DWORDl;pszPath 参数:指定的文件名。当uFlags的取值中不包含 SHGFI_PIDL时,可直接指定;否则pszPath要通过计算获得,不能直接指定;dwFileAttributes参数:文件属性,仅当uFlags的取值中包含SHGFI_USEFILEATTRIBUTES时有效,一般不用此参数;psfi 参数:返回获得的文件信息,是一个记录类型,有以下字段:hIcon: HICON; //文件的图标句柄iIcon: Integer; //图标的系统索引号dwAttributes: DWORD; //文件的属性值szDisplayName: array [0..MAX_PATH-1] of AnsiChar; //文件的显示名szTypeName: array [0..79] of AnsiChar; //文件的类型名cbFileInfo 参数:psfi的比特值;uFlags 参数:指明需要返回的文件信息标识符,常用的有以下常数:SHGFI_ICON; //获得图标SHGFI_DISPLAYNAME; //获得显示名SHGFI_TYPENAME; //获得类型名SHGFI_ATTRIBUTES;//获得属性SHGFI_LARGEICON; //获得大图标SHGFI_SMALLICON; //获得小图标SHGFI_PIDL;// pszPath是一个标识符函数SHGetFileInfo()的返回值也随uFlags的取值变化而有所不同。通过调用SHGetFileInfo()可以由psfi参数得到文件的图标句柄,但要注意在uFlags参数中不使用SHGFI_PIDL时,SHGetFileInfo()不能获得"我的电脑"等虚似文件夹的信息。二、图标的加载使用Delphi提供的TImageList组件,通过调用CommCtrl .pas中的函数ImageList_AddIcon()来加载得到的图标,并要保证其索引号与显示文本相对应。说明如下:function ImageList_AddIcon(ImageList: HIMAGELIST; //加载图标的ImageList句柄Icon: Hicon //加载的图标句柄 ): Integer; //返回图标在ImageList中的索引号在需要指明图标索引号时可使用ImageList_AddIcon()的返回值。三、图标和文本的绘图式输出对于组合框、列表框等不能直接显示图标的组件,由于要求显示图标的同时又要同时显示文本,可通过设置其相应的Style属性达到目的,示例如下:组合框:ComboBox1.Style:=csOwnerDrawVariable根据实际使用经验最好不要在ObjectInspector窗体中直接设置,而应将代码添加在程序的适当位置否则可能出现绘图区域高度不规则变化列表框:ListBox1.Style:=lbOwnerDrawVariable状态栏:StatusBar1.Panels[i].Style:= psOwnerDraw 不能使用简单状态栏,i是状态栏中要绘制图标的某一窗格索引号图形输出可使用TImageList的ImageList1.Draw()方法,而文本输出则可使用TCanvas的TextOut()方法,它由组件的Canvas属性继承得到,显然没有Canvas属性的组件不能使用此方法显示图标。对于可直接显示图标的组件,直接指定其Images、StateImages等需要的图标属性为相应的TimageList组件名,并通过指定图标的索引号则可显示图标。需要注意的是:在使用大图标时,必须先调用TImageList的CreateSize()方法指定可加载图标的尺寸,并且在每次调用TImageList的Clear方法后都要重新调用CreateSize()。使用TImageList的ImageList1.Clear方法清除已加载的图标,常在需要刷新时使用。
I also could not understand know why CSDN does not allow its member reply one's question more three times continuously.}if (pos('up')=0) or (pos('gz')=0) then
begin
showmessage('Fuck CSDN's goddam rules!');
end;//Jan. 12th, the memorable day,cet6 is coming towards me,a delphi fun...
大家帮帮忙,我加分啦
API:
BOOL UpdateResource(
HANDLE hUpdate, // 这个能取得
LPCTSTR lpType, // 修改图标应该是RT_ICON吧
LPCTSTR lpName, // 怎样取得这个??//需要修改的资源的名称
WORD wLanguage, // 怎样取得这个??//资源的语言类型, 可以使用MAKELANGID构造
LPVOID lpData, // 怎样取得这个??//存放资源的二进制数据的地址
DWORD cbData // 怎样取得这个??//用字节描述的数据的长度
); 解决上面的问题就可以了
使用软件EXESCOPE就可以了。
function aaa(hModule:HModule; lpszType:PChar; lpszName:PChar; lParam:LongInt):Boolean; stdcall;
var resname:string;
hh,lhandle:Thandle;
hresload:hrsrc;
hhicon:hicon;
lpResLock:^char;
begin
// if DWORD(ResName)<$10000 then
// Form1.Memo1.Lines.add(inttostr(dword(lpszName)));
// lhandle:=BeginUpdateResource(pchar('c:\notepad.exe'),false);hhicon:=findresource(hmodule,lpszname,rt_icon);
hResLoad:= LoadResource(hmodule, hhicon);
lpResLock:= LockResource(hResLoad);lhandle:=BeginUpdateResource(pchar('c:\notepad.exe'),false);
UpdateResource(lhandle,rt_icon,lpszname,LANG_CHINESE ,nil,
SizeofResource(lhandle,hhicon));
if endupdateresource(lhandle,false) then showmessage('ok');
Result:=True
end;procedure TForm1.Button1Click(Sender: TObject);
var hres:Thandle;
begin
hres:=LoadLibraryEx (PChar ('c:\notepad.exe'), 0,Load_Library_As_DataFile);
EnumResourceNames(hres,RT_ICON,@aaa,0);
freelibrary(hres);
end;
to thedream(梦幻使者): 解决了,别忘了告诉我!:) [email protected] MakeLangID(PrimaryLanguage,SubLanguage : word) : DWord;
begin
Result:=SubLanguage shl 10;
Result:=Result or PrimaryLanguage;
end; procedure change;
var
hResLoad:HRSRC; // handle to loaded resource
hExe:THANDLE; // handle to existing .EXE file
hRes:HRSRC; // handle/ptr. to res. info. in hExe
hUpdateRes:THANDLE; // update resource handle
lpResLock:^char; // pointer to resource data
return:BOOL;
begin
hExe := LoadLibrary('D:\M.exe');
if hExe=0 then messagebox(0,'error open exe','error',0); hRes := FindResource(hExe, 'MAINICON', RT_ICON);
if hRes=0 then messagebox(0,'can not find ico','error',0); hResLoad:= LoadResource(hExe, hRes);
if hResLoad=0 then messagebox(0,'Load error','error',0); lpResLock:= LockResource(hResLoad);
if lpReslock=nil then messagebox(0,'can not lock resource','error',0);
hUpdateRes:= BeginUpdateResource('d:\P.exe', FALSE);
if hUpdateRes=0 then messagebox(0,'can not open file for write','error',0); return:= UpdateResource(hUpdateRes, // update resource handle
RT_ICON, // change Icon resource
'MAINICON', // Icon name
MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), // neutral language
lpResLock, // ptr to resource info
SizeofResource(hExe, hRes)); // size of resource info.
if return=false then messagebox(0,'can not add res','error',0); if (not EndUpdateResource(hUpdateRes, FALSE)) then messagebox(0,'can not make change','error',0); if (not FreeLibrary(hExe)) then messagebox(0,'can not free exe','error',0);
end;
让后一个
application.Icon.Handle:=LoadIcon(hInstance,'yourICON');
就可以了
[email protected]