English 中文(简体)
Can multiple ProgIDs point to the same ClsID?
原标题:

I am working on a set of what are essentially plugins, which are COM servers. Each plugin has a set of configuration data which is managed by another component, the primary key to the configuration data is the plug-in s ProgID. When the plugin needs to access a configuration item, it makes a call and passes in its ProgID and the name of the property required. This is a legacy design and I must maintain backward compatibility.

I now have a requirement to load multiple instances of each plugin, with each instance having a different set of configuration data. The solution I m considering is to create multiple unique ProgIDs for each plugin, each ProgID would point to the single ClsId for the plugin. Thus, each instance of the plugin would be indentified by its ProgID, the ProgID is still used as the primary key for the configuration data and everything is 100% backward compatible.

So, the questions:

  1. Is this an acceptable technique? (multiple ProgIDs all pointing to a single ClsID).
  2. When my plugin loads, would it be able to tell which ProgID was used to create it?
最佳回答

Prog ids are typically used in two ways: to detect a class id corresponding to a prog id (CLSIDFromProgID() function) - this is used to later call CoCreateInstance() - and to detect a prog id for a given class id - this is usually used to display a human-friendly version of a class id.

Those mappings imply that there s a HKCR{ProgId}CLSID key with a default value equal to the class id and a HKCRCLSID{classid}ProgID key with a default value equal to the ProgId, which means that the mapping is one-to-one. You will just not be able to have more than one prog id under one class id.

A COM component is loaded by calling CoCreateInstance() which is passed a class id - obtained by any means possible, using CLSIDFromProgID() included. There re no ways for a component to tell how the class id was obtained.

问题回答

暂无回答




相关问题
How can i add a button to all windows explorer instances?

I am trying to add a button to one of the existing tool bars in any windows explorer instance. After much research i figured out that BHO (browser helper objects) are the best way to hook to ...

Hunting memory leaks

I m finding leaked heap blocks by using the following command in WinDbg !heap –l With each leaked heap block I get, I m running to following to get the stack trace. !heap -p -a leakedheapblock The ...

Why use CComBSTR instead of just passing a WCHAR*?

I m new to COM. What exactly is the advantage of replacing: L"String" with CComBSTR(L"String") I can see a changelist in the COM part of my .NET application where all strings are replaced in this ...

IThumbnailProvider and IInitializeWithItem

I am trying to develop an IThumbnailProvider for use in Windows 7. Since this particular thumbnail would also be dependant on some other files in the same directory, I need to use something other than ...

Getting a byte array from out of process C++ COM to C#

What s the best way to get a chunk of memory (i.e. void*) from a COM server to C#? We have been using an IStream (using CreateStreamOnHGlobal) and passing that back, which worked. However when we ...

COM Basic links

folks can you provide me the tutorial link or .pdf for learning basic COM?. i do google it.. still i recommend answers of stackoverflow so please pass me.. Thanks

热门标签