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--