user32.dll
의 기능을 사용하여 현재 커서의 아이콘 정보를 얻는 응용 프로그램을 작성했습니다. 일부 시간은 정상적으로 작동하지만 얼마 후에는 잘못된 정보를 제공하기 시작합니다. ICONINFO.hbmMask
(일부 음수 값 내가 Bitmap.HBitmap(bitmask)
에서 비트 맵 객체를 얻으려고 다음 줄에, 그것은 예외가 발생하는 경우), 그리고 :이 onwords에서GetIconInfo 함수가 제대로 작동하지 않습니다.
A Generic error occured in GDI+.
을 연속적 GetIconInfo
는 항상 음의 값을 반환으로,이 예외를 제공합니다 (이 코드는 루프에서 작업 중) ..
아무도이 문제가 무엇인지 말해 줄 수 있습니까? 그리고 다음 반복 예외를 피하는 방법? 여기
코드
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