Bitmap.GetHbitmap () does not work on XP

My NET 2.0 Winforms application works fine on Vista and Windows 7, but calling Bitmap.GetHbitmap() returns null in Windows XP (even with SP3). The main Bitmap is PNG and is loaded from resources. It is loaded correctly, so it is smaller than GetHbitmap() . I tried to cause both overloads with the same result.

+4
source share
1 answer

Watch out for memory leaks when debugging and working with .GetHBitmap

When you use this function, you need to delete the object manually.

MSDN example: http://msdn.microsoft.com/en-us/library/1dz311e4.aspx

 <System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")> _ Private Shared Function DeleteObject (ByVal hObject As IntPtr) As Boolean End Function Private Sub DemonstrateGetHbitmap() Dim bm As New Bitmap("Picture.jpg") Dim hBitmap As IntPtr hBitmap = bm.GetHbitmap() ' Do something with hBitmap. DeleteObject(hBitmap) End Sub 

and similar question: Error loading image using C #

Hello

0
source

All Articles