0

I'm using Visual Studio 2017. I've made an MFC project and added ATL support (VS did that for me). The software I'm developing requires the implementation of two custom interfaces and a category ID to be added to the registry under "Implemented Categories".

I have tried editing the .rgs file like below, but that did not work.

HKCR{
    NoRemove CLSID{
        ForceRemove {97ffeebf-bc8a-4faf-8672-0041459fbf52} = s 'ATLSimpleObject class'{
            LocalServer32 = s '%MODULE%'{
                val ServerExecutable = s '%MODULE_RAW%'
            }
            TypeLib = s '{1242F892-AA3F-4C37-A82D-4D0AB9DA6A2E}'
            Version = s '1.0'
            'Implemented Categories' {
                '{94A4D4AB-BC52-494e-9020-95C1CE4318B5}' {
                }
            }
        }
    }
}

I'm now trying using the BEGIN_CATEGORY_MAP macro, but the ID still does not get added to the registry.

using namespace ATL;

// CATLSimpleObject
class ATL_NO_VTABLE CATLSimpleObject :
    public CComObjectRootEx<CComSingleThreadModel>,
    public CComCoClass<CATLSimpleObject, &CLSID_ATLSimpleObject>,
    public IATLSimpleObject,
    public Interface1,
    public Interface2
{
public:
    CATLSimpleObject(){ }

    DECLARE_REGISTRY_RESOURCEID(311)    
    DECLARE_NOT_AGGREGATABLE(CATLSimpleObject)

    BEGIN_COM_MAP(CATLSimpleObject)
        COM_INTERFACE_ENTRY(IATLSimpleObject)
        COM_INTERFACE_ENTRY(Interface1)
        COM_INTERFACE_ENTRY(Interface2)
    END_COM_MAP()

    BEGIN_CATEGORY_MAP(CATLSimpleObject)
        IMPLEMENTED_CATEGORY(CATID_CategoryToBeImplemented)
    END_CATEGORY_MAP()

//Methods emitted
}

Where and how should I do it?

EDIT: Context (from a previous question of mine):

I'm working with some old robotics software which is able to get information from a COM object if it implements some predefined interfaces. Since this old software runs on Windows 2000, I want to use DCOM to (try to) avoid having to compile something for Windows 2000. (I am aware that the program that has to be called probably needs to work, or at least exist, on the Windows 2000 computer as well)

The other computer will be called through DCOM and will process an image using a configured set of steps. I would like a GUI to show the incoming and outgoing images and the ability to change the steps it undertakes.

Addition to context from previous question

The application needs to be an EXE COM server, the application I'm making it for does not accept dll's, unfortunately. I'm using MFC for the GUI components, because I thought that would be the easiest way. I have configured VS to "Use MFC in a shared DLL".

I've switched from .NET to C++, because out-of-proc COM in .NET is "quite complicated and brittle and not directly supported" -Hans Passant. And I have to agree so far: I managed to do more in C++ in 1 day, then with .NET in a week.

Daniël J
  • 107
  • 10
  • 2
    "It doesn't work" questions are hard to answer. Why did you start with MFC? Is this actually a project that generates an exe instead of a dll? That would explain registration problems. The host program no doubt requires an in-process server, a dll. – Hans Passant Mar 06 '18 at 09:58
  • I've appended context to my question. I started with MFC because it was mentioned in the robot manual and therefore I thought it would be best to use it, but it is by no means a requirement. This project indeed produces an exe, but VS is set to "Use MFC in a shared DLL". The robot software requires an exe, so an out-of-process server. – Daniël J Mar 06 '18 at 10:27
  • Nice when I guess correctly with just about no leads, you'll have to focus on getting registration correct. Now is not the time, you have a bunch of dragons to slay. Just do this by hand, using regedit.exe or a .reg file to keep going. – Hans Passant Mar 06 '18 at 11:34
  • Haha while typing it I knew there was something wrong and I even checked and saw it was 2017, but I forgot to change it. – Daniël J Mar 06 '18 at 12:05
  • @HansPassant The registration does actually work, it appears in the registry as a LocalServer32, but the part of Implemented categories doesn't get added. – Daniël J Mar 06 '18 at 12:10
  • `BEGIN_CATEGORY_MAP` + `IMPLEMENTED_CATEGORY` adds key to registry under "Implemented Categories" during COM server registration (run with /regserver). Does not it work for you? – Roman R. Mar 06 '18 at 17:08
  • @RomanR. It seems it does work a new project. There indeed seems to be something broken with registering, it must have worked at first, but it broke down after the keys were put into the registry which made me believe it still worked and the IMPLEMENTED CATEGORY was broken. But upon manual removing I see the keys aren't added anymore. I don't know how it broke, but it does work in a new project I've made so I'll continue there :) – Daniël J Mar 07 '18 at 08:27

0 Answers0