Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / May 2006

Tip: Looking for answers? Try searching our database.

Accessing embedded resources in .NET DLL through COM

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
hoptoit - 30 May 2006 22:06 GMT
I am writing a class library in VS .NET 2005 (VB.NET specifically) that will
be called from an existing program (that I have no control over) using COM.
One of the parameters it expects is the index of an icon embedded in the
DLL.  The catch is that other than a default icon that seems to be included
in the DLL automatically by Visual Studio (at index 0), none of the icons I
embed seem to be visible to the calling program.

I have tried various combinations of Build Actions, adding the icons as
Resources in the project Properties, all to no avail.  Everything I can find
on the web talks about how to access embedded resources programmatically
within the context of the .NET Framework, which is not particularly useful
in this instance.

I haven't done much COM programming, so it is quite possible I am missing
something obvious, but I am at my wit's end on this one.

Does anyone have any suggestions on how to either make the resources
embedded through Visual Studio visible through COM, or know of some other
mechanism for embedding resources that is more appropriate in this context?

Thanks!
--Lance--
"Peter Huang" [MSFT] - 31 May 2006 03:10 GMT
Hi Lance,

Thanks for your posting!

From your description, I understand that you have a .NET class library and
a legacy COM client(maybe VB6 or C++).
Now you will embedded the icon into the .NET class library and expose it to
the COM, so that the com client can access to it.
Now you want to access to the icons embedded in the .NET.

Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.
Based on my experience, we should use .NET related code to access to the
resource which is stored according to .NET namespace.(e.g. ResourceManager
class)
So can you post the code in the COM client about how will your code try to
access the icons?

Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
HopToIt - 31 May 2006 16:22 GMT
Correct, I am writing a .NET DLL that will provide "add-in" functionality to
an existing COM executable.  The COM executable specifies an interface that
it expects add-in DLLs to use.  

However, I do not have the ability to modify the way the COM executable
works, so whatever code it uses to access the icons is the code I am stuck
with (so unfortunately using the .NET GetManifestResource* functions is out).


I do have access to the C++ source code, and with a little bit of searching,
it looks like the executable is using the ExtractIcon function declared in
shellapi.h (a Win32 API function, I think?), which expects a zero-based index
specifying which icon to retrieve.  Here is the actual code snippet:

HICON    hIcon = NULL;
int    nIconIndex = m_wizard.GetIconIndex();
if (nIconIndex >= 0)
    hIcon = ExtractIcon(AfxGetInstanceHandle(), m_strPath, nIconIndex);

m_wizard is the COM interface wrapper to access my DLL.
GetIconIndex() is the function in my DLL that provides an index to which
icon I want displayed.
m_strPath is the path to my DLL.

So, I guess the question is how do I embed my icons such that ExtractIcon
will be able to find them?

Thanks so much for your help,
--Lance--

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.