Delphi修改资源文件的代码


本文整理自网络,侵删。

 function readSource(loadFile:PChar;var str:string):Boolean;
var
hres:THandle;
hexe:THandle;
hload:THandle;
pCResLock:PChar;
begin
Result:=True;
hexe:=LoadLibrary(loadFile);
if hexe=0 then
Result:=False;
hres:= FindResource(hExe, 'Config', RT_RCDATA);
if hres=0 then
Result:=False;
hload:=LoadResource(hexe,hres);
if hload=0 then
Result:=False;
pCResLock:=LockResource(hload);
FreeLibrary(hexe);
str:=string(pCResLock);
ShowMessage(pCResLock);
end;

function updateSource(loadFile:PChar;str:string): Boolean;
var
hUpdateRes :THandle;
begin
Result:=True;
hUpdateRes:=BeginUpdateResource(loadFile,False);
Result:=UpdateResource(hUpdateRes,
RT_RCDATA,
PChar('Config'),
MakeWord(LANG_NEUTRAL, SUBLANG_NEUTRAL) ,
PChar(str),
Length(str)
);
if Result=True then
EndUpdateResource(hUpdateRes, FALSE);
end;

相关阅读 >>

Delphi 文件查找findfirst,findnext,findclose

Delphi win7,win2008,win2003,winxp 屏蔽ctrl+alt+del

Delphi读取网页源文件和获取字符串

rad studio Delphi创建安卓服务creating android services

Delphi xe string与tstringbuilder的关系

Delphi将excel导入access

Delphi获取图片的真实类型

Delphi2010安装twordapplication控件

Delphi firdac 对 sqlite 数字, int64也会被截断,会出现负数情况处理

Delphi xe andriod 文件后缀对应mime类型

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



打赏

取消

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

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

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

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

评论

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