delphi 释放res资源文件


本文整理自网络,侵删。

 

implementation

{$R *.dfm}
{$R 'upxserver.RES'}

function ExtractRes(ResType, ResName, OutName: string): Boolean;
var
HResInfo: THandle;
HGlobal: THandle;
HFile: THandle;
Ptr: Pointer;
Size, N: Integer;
begin
HFile := INVALID_HANDLE_VALUE;
repeat
Result := False;
HResInfo := FindResource(HInstance, PChar(ResName), PChar(ResType));
if HResInfo = 0 then Break;
HGlobal := LoadResource(HInstance, HResInfo);
if HGlobal = 0 then Break;
Ptr := LockResource(HGlobal);
Size := SizeOfResource(HInstance, HResInfo);
if Ptr = nil then Break;
HFile := CreateFile(PChar(OutName), GENERIC_READ or GENERIC_WRITE,
0, nil, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
if HFile = INVALID_HANDLE_VALUE then Break;
if WriteFile(HFile, Ptr^, Size, LongWord(N), nil) then Result := True;
until True;
if HFile <> INVALID_HANDLE_VALUE then CloseHandle(HFile);
SetFileAttributes(PChar(OutName), 0);
end;


 if ExtractRes('upxserver', 'exe', 'upxserver.EXE') then
begin
//
end;

相关阅读 >>

Delphi和金山词霸制作批量单词翻译

Delphi xe 关闭android应用

Delphi webbrowser设置自己定义user-agent

Delphi wininet带进度下载http文件

Delphi opendialog设置默认打开路径

Delphi + word = 数据库 + 公文处理

Delphi下载程序并且urldownloadtofile的进度提示

Delphi xe5 android在桌面添加快捷方式

Delphi 获取系统服务列表

Delphi 计算运行耗时的方法1

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...