Using a Win32 resource DLL in VB.NET?

N

Nak

Hi there,

This might sound like a dumb question but how would I use a Win32
resource DLL in VB.NET? I presumed there were API's for this purpose but am
unsure which ones, my API guide has nothing of relevance in the "Resources"
section and I've never actually done this in the past.

Thanks loads in advance!

Nick.
 
G

Gary Chang[MSFT]

Hi Nak,

...using the pinvoke to call the API LoadLibrary to load your resource DLL,
then call the FindResource or LoadResource to load the variours resources,
or call the follwing APIs tto load specific resouce:
FormatMessage
LoadAccelerators
LoadBitmap
LoadCursor
LoadIcon
LoadMenu
LoadString

and when your program terminates, don't forget to call the API FreeLibrary
to free that resource DLL..


Thanks for your understanding!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
 
N

Nak

Hi Gary,

Thanks for the very informative answer, just what I needed, much
appreciation your way!

Nick.
 
N

Nak

Hi again,

I'm having loads of fun with loading resources from a DLL, apparently
the module can't be found! What I'm trying to do is load a ".msstyles" file
(which is a Win32 resource DLL) and obtain resources from it.

So far, I have the following

Private Declare Function LoadLibrary Lib "kernel32.dll" Alias "LoadLibraryW"
(ByVal lpLibFileName As String) As IntPtr

Dim pIPrLibHandle As IntPtr = LoadLibrary(iFileName)
If (pIPrLibHandle.Equals(IntPtr.Zero)) Then
Throw New Win32Exception(Err.LastDllError)
Else
'Loaded!
End If

I've tried a few deformations of the LoadLibrary declaration, and even
tried LoadLibraryEx and GetModuleHandle, but they *all* return the same
error. The following URL shows basically what I am trying to do in C++,

http://www.winehq.org/hypermail/wine-devel/2004/02/0082.html

I have tried placing the file inside of the executable path too but
still I get an exception saying that the module cannot be found. Any ideas
on this one would be greatly appreciated!

Nick.
 
N

Nak

Ignore me, I should have read the initial posts correctly and used PInvoke
from the start. Cheers again!

Nick.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top