Old Style Resource "embedding" in VB.NET... please help.

M

Matt

I'm working on a plug-in for an application called DesktopSideBar for
Windows. It emulates to some degree the Longhorn sidebar. The SDK for
DesktopSideBar supports .NET plug-in development through COM Interop
and a provided reference DLL. In the SDK are two included samples...
One, called RecycleBin is written entirely in unmanaged C++ as a
normal DLL. The second, StickerPanel, is written in C#. My first
exercise was porting StickerPanel to VB.NET to get a feel for the SDK
and I prefer VB.NET to C#.

Most of the functionality is a very seamless fit with the .NET
framework. However, there are a couple of examples I can NOT figure
out how to emulate in .NET. One of the first methods that is required
is:

Public Overridable Sub RegisterPanel(ByVal panelClass As String, ByVal
panelCaption As String, ByVal panelDescription As String, ByVal
panelIcon As String, ByVal panelCategory As String, ByVal categoryIcon
As String, ByVal panelFiles As String, ByVal pluginCookie As Integer)

The included C# example leaves the Icon variables blank. This has the
effect of leaving the icon blank on the "Add Plugin" panel where all
installed plug-ins are listed. I really want to provide this. The
problem is that either Icon parameter is a String format... and it's
not a path. In the C++ example it's handled:

char szPath[_MAX_PATH];
GetModuleFileName(_AtlBaseModule.GetResourceInstance(),szPath,sizeof(szPath));

std::stringstream panelIcon;
panelIcon<<szPath<<","<<IDB_ICONS<<",0";

CSidebar sidebar(pSidebar);
sidebar.RegisterPanel(
"RecycleBinPanel",
"recyclebin",
"recyclebin_desc",
panelIcon.str(),
"system_cat",
",254,4",
"",
pluginCookie);

Now, I used to do C++ development exclusively and this is certainly
not difficult to understand... mostly anyway. Unfortunately the author
of DesktopSidebar is just one person and so the SDK just includes the
2 samples, the reference DLL, some Includes for C++ development, and
general instructions. There is no documentation for the methods
available. So, the code above basically gets the full path to itself,
a DLL in the DesktopSideBar directory. Then it creates a string that
looks something like this: "C:\Program Files\Desktop
Sidebar\recyclebin.dll,100,0". I used 100 because that is the provided
resource ID within the project specified by IDB_ICONS. In the C++
code, the bitmap used, "icons.bmp" is included as a resource in the
DLL. It's a bitmap with 2 images, so I think the ",0" refers to the
first image.

Now, in VB.NET we can also include bitmaps (or whatever we want)
inside the DLL by making it an embedded resource. However, there are
several problems... one is that there is no resourceID to reference
(which I require in this weird case). Now, I can use Ildasm.exe on the
compiled DLL to get more information, for instance in my DLL
Ildasm.exe shows me this:
..mresource /*28000002*/ public 'dssystemuptime.up.bmp'

So, I guessed that my resourceID could be 28000002 and so I tried
using the same semantics (even used the same bitmap). However, all I
got was a black blob. This is more than I got before, but I think I'm
missing something. I don't think the embedding in VB.NET works in the
same way it does/did under C++. Using an application, "Resource
Grabber" I was able to open the Recyclebin C++ DLL and see the bitmap.
When looking at my DLL developed in VB.NET, I don't see the bitmap.
However, it IS there as I can get to it just fine using the call:
Me.GetType().Assembly.GetManifestResourceStream(...) and then creating
a bitmap from that.

Does anyone have a clue on how I could procede or is this just
something that isn't going to work?
 
H

Herfried K. Wagner [MVP]

* (e-mail address removed) (Matt) scripsit:
Now, in VB.NET we can also include bitmaps (or whatever we want)
inside the DLL by making it an embedded resource. However, there are
several problems... one is that there is no resourceID to reference
(which I require in this weird case). Now, I can use Ildasm.exe on the
compiled DLL to get more information, for instance in my DLL
Ildasm.exe shows me this:
.mresource /*28000002*/ public 'dssystemuptime.up.bmp'

You will have to use "vbc.exe" for compilation with
"/win32resource:<filename>" specified in order to embed an old-style
Win32 resource file.
 

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