本文整理自网络,侵删。
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 从给定字符串中截取n个字节的字符(解决汉字截取乱码问题)
Delphi webbrowser通过遍历id查找元素是否存在
Delphi中exit,abort,break,continue的区别介绍
Delphi 5-7 桥接让Delphi xe2 datasnap中间层支持Delphi低版本开发客户端
更多相关阅读请进入《Delphi》频道 >>