Accessing bitmap resources in C ++ DLL from VB6

I have a C ++ DLL including bitmap resources generated by Visual Studio.

While I can load the DLL in VB6 using LoadLibrary, I cannot load image resources either with LoadImage or LoadBitmap. When I try to get an error using GetLastError (), it doesn't return any errors.

I tried using LoadImage and LoadBitmap in another C ++ program with the same DLL and they work without issue.

Is there any other way to access bitmaps of resources in a C ++ DLL using VB6?

+1


source to share


3 answers


Since you are using the numeric bitmap ID as a string, you need to add a "#" before it:

DLLHandle = LoadLibrary("Mydll.dll")
myimage = LoadBitmap(DLLHandle, "#101")  ' note the "#"

      



In C ++, you can also use the MAKEINTRESOURCE macro, which is simply LPCTSTR:

imagehandle = LoadBitmap(DLLHandle, MAKEINTRESOURCE(101));

      

+1


source


You have the right idea. You are probably wrong. Maybe you could show some code as I can't guess what you are going through.



0


source


In VB6:

Private declaration Function LoadLibrary Lib "kernel32" Alias ​​"LoadLibraryA" (ByVal lpLibFileName As String) As Long

Private declaration Function LoadBitmap Lib "user32" Alias ​​"LoadBitmapA" (ByVal hInstance As Long, ByVal lpBitmapName As String) As Long

DLLHandle = LoadLibrary ("Mydll.dll")

myimage = LoadBitmap (DLLHandle, "101")

comes with myimage as 0, although DLLHandle is nonzero, but in C ++:

imagehandle = LoadBitmap (DLLHandle, LPCSTR (101));

works!

Thank you so much

0


source







All Articles