GetIconInfo
の機能を使用して現在のカーソルのアイコン情報を取得しているアプリケーションを作成しました。しばらくの間うまく動作しますが、しばらくしてからICONINFO.hbmMask
(負の値)、と私はBitmap.HBitmap(bitmask)
からBitmapオブジェクトを取得しようと次の行に、それは例外スローした場合:GetIconInfo
は常にこのすべてのコードがある(負の値を返すようそこからGetIconInfo関数が正常に動作しません
A Generic error occured in GDI+.
はonwords、それが継続的に、この例外を与えますループで作業中)..
誰でもこの問題が何であるか教えていただけますか?次の反復例外を回避する方法は?ここで
コードが
ある while (true)
{
//DLLimport User32.dll
PlatformInvokeUSER32.ICONINFO temp;
//Get the current cursor
IntPtr curInfo = GetCurrentCursor();
Cursor cur;
Icon ic;
if (curInfo != null && curInfo.ToInt32() != 0 && isOSelected)
{
cur = CheckForCusrors(curInfo);
try
{
//Dllimport User32.dll
//after some time the temp.hbmMask begin to get -ive vlaue from following function call
PlatformInvokeUSER32.GetIconInfo(curInfo, out temp);
if (temp.hbmMask != IntPtr.Zero)
{
//due to negative value of hbmMask the following function generates an exception
Bitmap bitmask = Bitmap.FromHbitmap(temp.hbmMask);
ic = Icon.FromHandle(curInfo);
Bitmap bmpCur = ic.ToBitmap();
}
}
catch (Exception ee)
{
//Exception message is
//A Generic error occured in GDI+
//and this loop begins to throw exception continuously
}
}
}// while ended
コードを投稿してみてください。 –
多分この資料は役立ちます:[GDIリソースリークのデバッグ](https://blogs.msdn.microsoft.com/oldnewthing/20170519-00/?p=96195) – coz