我用下面的方法提取不到,只完成了一半的功能,请大家指点一下:
Function EnumResName(hModule: HMODULE; lpType, lpName: PChar;lParam: Longint):BOOL;stdcall;procedure TForm1.btn1Click(Sender: TObject);
begin
EnumResourceNames(0, RT_STRING, @EnumResName, 0);
end;Function EnumResName(hModule: HMODULE; lpType, lpName: PChar; lParam: Longint):BOOL; //回var
ResString: String;
hResource: HRSRC;
hglob: HGLOBAL;
Buffer: array [0..1023] of char;
Begin
result := True;
if lpType <> RT_STRING then exit;
//
hResource:=FindResource(hModule, lpName, RT_STRING);
//
hglob:=LoadResource(hModule, hResource); SetString(ResString, Buffer,
LoadString(FindResourceHInstance(hModule), hglob, Buffer, SizeOf(Buffer)));
Form1.ValueListEditor1.Strings.Add(Format('%s=%s', [IntToStr(Integer(lpName)), ResString])) //Form1.ValueListEditor1.Strings.Add(Format('%s=%s', [IntToStr(Integer(lpName)), IntToStr(Integer(hResource))]))
end;
Function EnumResName(hModule: HMODULE; lpType, lpName: PChar;lParam: Longint):BOOL;stdcall;procedure TForm1.btn1Click(Sender: TObject);
begin
EnumResourceNames(0, RT_STRING, @EnumResName, 0);
end;Function EnumResName(hModule: HMODULE; lpType, lpName: PChar; lParam: Longint):BOOL; //回var
ResString: String;
hResource: HRSRC;
hglob: HGLOBAL;
Buffer: array [0..1023] of char;
Begin
result := True;
if lpType <> RT_STRING then exit;
//
hResource:=FindResource(hModule, lpName, RT_STRING);
//
hglob:=LoadResource(hModule, hResource); SetString(ResString, Buffer,
LoadString(FindResourceHInstance(hModule), hglob, Buffer, SizeOf(Buffer)));
Form1.ValueListEditor1.Strings.Add(Format('%s=%s', [IntToStr(Integer(lpName)), ResString])) //Form1.ValueListEditor1.Strings.Add(Format('%s=%s', [IntToStr(Integer(lpName)), IntToStr(Integer(hResource))]))
end;
function EnumResName(
hModule: HMODULE;
lpszType: LPCTSTR;
lpszName: LPTSTR;
lParam: Longint
): BOOL; stdcall;
var
hResource: HRSRC;
hglob: HGLOBAL;
vPointer: PWideChar;
Begin
Result := True;
hResource := FindResource(hModule, lpszName, RT_STRING);
hglob := LoadResource(hModule, hResource);
try
vPointer := LockResource(hglob);
TForm1(lParam).ValueListEditor1.InsertRow(IntToStr(Integer(lpszName)),
vPointer, True);
finally
UnlockResource(hglob);
end;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
EnumResourceNames(HInstance, RT_STRING, @EnumResName, Integer(Self));
end;
我努力看看这个Demo
C:\Program Files\Borland\Delphi6\Demos\ResXplor