C
cking331
Unregistered / Unconfirmed
GUEST, unregistred user!
编写资源编译成Res然后包成Dll调用
NEW ICO Pause.ico //加入Icon
modify ICO Modify.ico
var
hDllHandle,hIcon: THandle;
Icon: TIcon;
FStream: TStream;
begin
hDllHandle := LoadLibrary(pChar(FsDllName));
if hDllHandle <> 0 then
begin
if FindResource(hDllHandle, PChar(ResName), 'ICO') <> 0 then
begin
//hIcon := LoadIcon(hDllHandle, pChar(ResName);
//if hIcon <> 0 then
// Image1.Picture.Icon.Handle := hIcon;
FStream := TResourceStream.Create(hDllHandle, Pchar(ResName), 'ICO');
try
Icon := TIcon.Create;
Icon.LoadFromStream(FStream);
Image1.Picture.Icon.Assign(Icon);
finally
FStream.Free;
end;
end;
end;
FreeLibrary(hDllHandle);
end;
我用流的方式是可以导出图片资源的,但是流的方式不太稳定,有时会报莫名的错误
所有我就改成
//hIcon := LoadIcon(hDllHandle, pChar(ResName);
//if hIcon <> 0 then
// Image1.Picture.Icon.Handle := hIcon;
现在这个方法得到的hIcon句柄总是为零(hDllHandle是不为零的,说明Dll有导入进来)
请各位高手指点小弟一下。
NEW ICO Pause.ico //加入Icon
modify ICO Modify.ico
var
hDllHandle,hIcon: THandle;
Icon: TIcon;
FStream: TStream;
begin
hDllHandle := LoadLibrary(pChar(FsDllName));
if hDllHandle <> 0 then
begin
if FindResource(hDllHandle, PChar(ResName), 'ICO') <> 0 then
begin
//hIcon := LoadIcon(hDllHandle, pChar(ResName);
//if hIcon <> 0 then
// Image1.Picture.Icon.Handle := hIcon;
FStream := TResourceStream.Create(hDllHandle, Pchar(ResName), 'ICO');
try
Icon := TIcon.Create;
Icon.LoadFromStream(FStream);
Image1.Picture.Icon.Assign(Icon);
finally
FStream.Free;
end;
end;
end;
FreeLibrary(hDllHandle);
end;
我用流的方式是可以导出图片资源的,但是流的方式不太稳定,有时会报莫名的错误
所有我就改成
//hIcon := LoadIcon(hDllHandle, pChar(ResName);
//if hIcon <> 0 then
// Image1.Picture.Icon.Handle := hIcon;
现在这个方法得到的hIcon句柄总是为零(hDllHandle是不为零的,说明Dll有导入进来)
请各位高手指点小弟一下。