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图像hash算法,关于图像相似度问题

tstringgrid 添加鼠标拖动功能

Delphi string内存结构

Delphi 获取\xxx\xxxx\1234最后一级名称

winapi 字符及字符串函数(7): ischarlower - 是否是个小写字母

Delphi中dbgrid控件数据库点击某列按序排列

Delphi 字符串加密与解密函数

Delphi 使用edge browser浏览器组件

Delphi第三方控件通用安装方法

Delphi getforegroundwindow 与 getactivewindow 的区别

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



打赏

取消

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

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

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

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

评论

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