私は次の問題に遭遇しました:
私のDelphi7プログラムは、WinXP / Vista / 7を実行しているほとんどのコンピュータでスムーズに実行されますが、一部の古いWindows XPインストール(ごく一部)では、次の問題が発生します。
システムイメージリストがあり、システムイメージリストのコピーに自分のアイコンを追加しています。アイコンを追加すると、「無効な画像サイズ」が表示されます。EInvalidOperationエラー。
問題のコードは次のとおりです。
function GetSystemLargeIconsList: TCustomImageList;
// This gets the system image list.
var
SysIL: HImageList;
SFI: TSHFileInfo;
MyImages: TCustomImageList;
begin
SysIL := SHGetFileInfo('', 0, SFI, SizeOf(SFI),
SHGFI_SYSICONINDEX or SHGFI_LARGEICON);
if SysIL <> 0 then begin
MyImages:=TCustomImageList.Create(nil);
// Assign the system list to the component
MyImages.Handle := SysIL;
// The following prevents the image list handle from being
// destroyed when the component is.
MyImages.ShareImages := TRUE;
Result:=MyImages;
end;
end;
var
DocumentImgList: TCustomImageList;
IconToAdd: TIcon;
begin
DocumentImgList:=GetSystemLargeIconsList;
Documents.LargeImages:=DocumentImgList;
Documents.SmallImages:=DocumentImgList;
IconToAdd:=TIcon.Create;
DocumentListIcons.GetIcon(0, IconToAdd);
DocumentImgList.AddIcon(IconToAdd); ----> this is the line of the exception
問題をさらに悪化させるために、私はTPngImageListコンポーネントを使用していますが、コードによると、標準のDelphi関数を呼び出しているようです。
if TObject(Self) is TPngImageList
then if Image = nil
...
else begin
Patch := FindMethodPatch('AddIcon');
if Patch <> nil
then begin
Patch.BeginInvokeOldMethod;
try
Result := TCustomImageList(Self).AddIcon(Image); ----> this is where the exception happens
finally
Patch.FinishInvokeOldMethod;
end;
end
else Result := -1;
end;
最近、この問題が発生しているコンピューターの1つで、uxtheme.dllまたはexplorer.exeのいずれかにWindowsスキンプログラムがパッチされていることがわかりました。
したがって、誰かまたはプログラムが、Delphiプログラムをクラッシュさせるような方法でシステムイメージリストをハッキングしていると思います。
これを修正する方法について何かアイデアはありますか?
ありがとう!