<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic COM Property Registration in ObjectARX Forum</title>
    <link>https://forums.autodesk.com/t5/objectarx-forum/com-property-registration/m-p/7163506#M8065</link>
    <description>&lt;P&gt;I have my COM Property interfaces for my custom entities in my ARX file and I'm having problems with the registration. We try to register the ARX during installation of our app using &lt;STRONG&gt;regsvr32&lt;/STRONG&gt; - but of course this needs to 'run' the server, which means it needs to resolve all of its dependencies, including the AutoCAD ones.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To get this to work you need to add the AutoCAD installation path(s) to your path environment variable, then run &lt;STRONG&gt;regsvr32&lt;/STRONG&gt; as admin - relatively straightforward to do manually - a little trickier during an install.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(I think unresolved dependencies is also the reason my attempts at internal registration fail)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another approach would be to script the reg entries, but then we need to get the installation path into there for the &lt;STRONG&gt;InProcServer&lt;/STRONG&gt; entries.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is reg-free COM specification via the manifest file an option? If so, is it enough to just have the entries in the manifest? Can you embed the manifest in that situation?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do you handle this?&lt;/P&gt;</description>
    <pubDate>Tue, 20 Jun 2017 03:25:47 GMT</pubDate>
    <dc:creator>Kyudos</dc:creator>
    <dc:date>2017-06-20T03:25:47Z</dc:date>
    <item>
      <title>COM Property Registration</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/com-property-registration/m-p/7163506#M8065</link>
      <description>&lt;P&gt;I have my COM Property interfaces for my custom entities in my ARX file and I'm having problems with the registration. We try to register the ARX during installation of our app using &lt;STRONG&gt;regsvr32&lt;/STRONG&gt; - but of course this needs to 'run' the server, which means it needs to resolve all of its dependencies, including the AutoCAD ones.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To get this to work you need to add the AutoCAD installation path(s) to your path environment variable, then run &lt;STRONG&gt;regsvr32&lt;/STRONG&gt; as admin - relatively straightforward to do manually - a little trickier during an install.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(I think unresolved dependencies is also the reason my attempts at internal registration fail)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another approach would be to script the reg entries, but then we need to get the installation path into there for the &lt;STRONG&gt;InProcServer&lt;/STRONG&gt; entries.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is reg-free COM specification via the manifest file an option? If so, is it enough to just have the entries in the manifest? Can you embed the manifest in that situation?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do you handle this?&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jun 2017 03:25:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/com-property-registration/m-p/7163506#M8065</guid>
      <dc:creator>Kyudos</dc:creator>
      <dc:date>2017-06-20T03:25:47Z</dc:date>
    </item>
    <item>
      <title>Re: COM Property Registration</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/com-property-registration/m-p/7163620#M8066</link>
      <description>&lt;P&gt;I use this method for registration, regardless of whether or not the user has administrator rights:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//- DllRegisterServer - Adds entries to the system registry
//STDAPI DllRegisterServer (void) {
//  //- Registers object, typelib and all interfaces in typelib
//  return (_AtlModule.RegisterServer (TRUE)) ;
//}
typedef void (*OaEnablePerUserTLibRegistration)();
STDAPI DllRegisterServer(void)
{
  HINSTANCE hInstOle32=NULL;
  try
  {
    HRESULT hr = _AtlModule.RegisterServer(TRUE);
    if(FAILED(hr))
    {
      hInstOle32 = LoadLibrary(_T("Oleaut32.dll"));
      if(hInstOle32)
      {
        OaEnablePerUserTLibRegistration lr=(OaEnablePerUserTLibRegistration)GetProcAddress(hInstOle32,("OaEnablePerUserTLibRegistration"));

        if(lr!=NULL)
        {
          lr(); 
          hr = _AtlModule.RegisterServer(TRUE);
          if(SUCCEEDED(hr))
          {
            FreeLibrary(hInstOle32);
            return hr;
          }
        }       
      }   

      HKEY hKCr;
      hr=RegOpenKeyEx(HKEY_CURRENT_USER,_T("Software\\Classes"),0,KEY_READ,&amp;amp;hKCr);
      if(hr!=ERROR_SUCCESS)
      {
        return hr;
      }
      hr = RegOverridePredefKey(HKEY_CLASSES_ROOT,hKCr);
      RegCloseKey(hKCr);
      if(FAILED(hr))
      {
        return hr;
      }   
      hr = _AtlModule.RegisterServer(TRUE);
      RegOverridePredefKey(HKEY_CLASSES_ROOT,NULL);
      hr=S_OK;
    }
    if(hInstOle32)
      FreeLibrary(hInstOle32);
    return hr;
  }
  catch (...)
  {
    if(hInstOle32)
      FreeLibrary(hInstOle32);
    return E_FAIL;
  }
}
&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;Note:&lt;/STRONG&gt; The corresponding rgs-file must not contain HKLM sections.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jun 2017 05:49:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/com-property-registration/m-p/7163620#M8066</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2017-06-20T05:49:51Z</dc:date>
    </item>
    <item>
      <title>Re: COM Property Registration</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/com-property-registration/m-p/7166417#M8067</link>
      <description>&lt;P&gt;Thanks Alexander - it is useful to have this code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It seems to work fine on Windows 7, but not reliably on Win10 (it's Win10 giving me problems in general!)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think we'll probably go with a reg file, for predicatability.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2017 00:23:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/com-property-registration/m-p/7166417#M8067</guid>
      <dc:creator>Kyudos</dc:creator>
      <dc:date>2017-06-21T00:23:40Z</dc:date>
    </item>
    <item>
      <title>Re: COM Property Registration</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/com-property-registration/m-p/13339135#M8068</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/542776"&gt;@Kyudos&lt;/a&gt;&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/481027"&gt;@Alexander.Rivilis&lt;/a&gt;&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/80782"&gt;@OysteinW&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm encountering the same issue with registering the COM server. I attempted to use the provided code, but I'm receiving some unusual syntax errors at compile time—even though IntelliSense doesn't highlight any problems.&amp;nbsp;Any guidance on how to resolve these errors would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="furqananees2007_0-1740508828759.png" style="width: 1149px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1471009i0F60F902A4F3FAA7/image-dimensions/1149x257?v=v2" width="1149" height="257" role="button" title="furqananees2007_0-1740508828759.png" alt="furqananees2007_0-1740508828759.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This is the main C++ file that is automatically generated when creating a COM wrapper project using the ObjectARX Wizard.&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;#include "StdAfx.h"

#if defined(_DEBUG) &amp;amp;&amp;amp; !defined(AC_FULL_DEBUG)
#error _DEBUG should not be defined except in internal Adesk debug builds
#endif

#include "resource.h"
#include &amp;lt;initguid.h&amp;gt;
#include "COMSPPC_i.h"
#include "COMSPPC_i.c"
#include "acadi_i.c"

#include &amp;lt;oleauto.h&amp;gt;
#include &amp;lt;windows.h&amp;gt;
#include &amp;lt;tchar.h&amp;gt;

#include "SPPointCloud.h" // Include your custom entity header

#include "SPPointCloudCOM.h"

CComModule _Module;

BEGIN_OBJECT_MAP(ObjectMap)
    OBJECT_ENTRY(CLSID_SPPointCloudCOM, CSPPointCloudCOM) // Register your COM class
END_OBJECT_MAP()

/////////////////////////////////////////////////////////////////////////////
// DLL Entry Point
extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{
    if (dwReason == DLL_PROCESS_ATTACH)
    {
        _Module.Init(ObjectMap, hInstance);
        DisableThreadLibraryCalls(hInstance);

        // Check if the DBX module is loaded; if not, load it
        if (!::acrxAppIsLoaded(_T("SPPointCloud.dbx"))) // Replace with your DBX module name
        {
            if (!acrxLoadModule(_T("SPPointCloud.dbx"), false, true))
                return FALSE; // This will trigger a DLL_PROCESS_DETACH right away
        }

        // Bump the reference count
        acrxLoadModule(_T("SPPointCloud.dbx"), false, false);
    }
    else if (dwReason == DLL_PROCESS_DETACH)
    {
        _Module.Term();

        // Try to decrease the refcount on the DBX module
        acrxUnloadModule(_T("SPPointCloud.dbx"));
    }
    return TRUE;    // ok
}

/////////////////////////////////////////////////////////////////////////////
// Used to determine whether the DLL can be unloaded by OLE

STDAPI DllCanUnloadNow(void)
{
    return (_Module.GetLockCount() == 0) ? S_OK : S_FALSE;
}

/////////////////////////////////////////////////////////////////////////////
// Returns a class factory to create an object of the requested type

STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
    return _Module.GetClassObject(rclsid, riid, ppv);
}

/////////////////////////////////////////////////////////////////////////////
// DllRegisterServer - Adds entries to the system registry


typedef void (*OaEnablePerUserTLibRegistration)();
STDAPI DllRegisterServer(void)
{
    HINSTANCE hInstOle32 = NULL;
    try
    {
        HRESULT hr = _Module.RegisterServer(TRUE);
        if (FAILED(hr))
        {
            hInstOle32 = LoadLibrary(_T("Oleaut32.dll"));
            if (hInstOle32)
            {
                OaEnablePerUserTLibRegistration lr = (OaEnablePerUserTLibRegistration)GetProcAddress(hInstOle32, ("OaEnablePerUserTLibRegistration"));

                if (lr != NULL)
                {
                    lr();
                    hr = _Module.RegisterServer(TRUE);
                    if (SUCCEEDED(hr))
                    {
                        FreeLibrary(hInstOle32);
                        return hr;
                    }
                }
            }

            HKEY hKCr;
            hr = RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\Classes"), 0, KEY_READ, &amp;amp;hKCr);
            if (hr != ERROR_SUCCESS)
            {
                return hr;
            }
            hr = RegOverridePredefKey(HKEY_CLASSES_ROOT, hKCr);
            RegCloseKey(hKCr);
            if (FAILED(hr))
            {
                return hr;
            }
            hr = _Module.RegisterServer(TRUE);
            RegOverridePredefKey(HKEY_CLASSES_ROOT, NULL);
            hr = S_OK;
        }
        if (hInstOle32)
            FreeLibrary(hInstOle32);
        return hr;
    }
    catch (...)
    {
        if (hInstOle32)
            FreeLibrary(hInstOle32);
        return E_FAIL;
    }
}

/////////////////////////////////////////////////////////////////////////////
// DllUnregisterServer - Removes entries from the system registry

STDAPI DllUnregisterServer(void)
{
    _Module.UnregisterServer();
    return S_OK;
}
&lt;/LI-CODE&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Tue, 25 Feb 2025 17:49:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/com-property-registration/m-p/13339135#M8068</guid>
      <dc:creator>furqananees2007</dc:creator>
      <dc:date>2025-02-25T17:49:36Z</dc:date>
    </item>
    <item>
      <title>Re: COM Property Registration</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/com-property-registration/m-p/13339337#M8069</link>
      <description>&lt;P&gt;Ultimately we created self-registering COM classes using RGS files in the resources. Based on this method by Michael Geddes:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.codeproject.com/Articles/6319/Registry-Map-for-RGS-files" target="_blank" rel="noopener"&gt;https://www.codeproject.com/Articles/6319/Registry-Map-for-RGS-files&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And then simply calling&amp;nbsp;DllRegisterServer in DllMain&lt;/P&gt;</description>
      <pubDate>Tue, 25 Feb 2025 20:15:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/com-property-registration/m-p/13339337#M8069</guid>
      <dc:creator>Kyudos</dc:creator>
      <dc:date>2025-02-25T20:15:57Z</dc:date>
    </item>
    <item>
      <title>Re: COM Property Registration</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/com-property-registration/m-p/13339368#M8070</link>
      <description>&lt;P&gt;To expand a bit more. Our module is an &lt;STRONG&gt;&lt;FONT face="courier new,courier" color="#FF0000"&gt;ATL::CAtlMfcModule&lt;/FONT&gt;&lt;/STRONG&gt; that looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;//------------------------------------------------------------------------------
class OurModule : public ATL::CAtlMfcModule
//------------------------------------------------------------------------------
{
public:
	DECLARE_LIBID(APPLIBID);
	#if defined (_M_X64)
		DECLARE_REGISTRY_APPID_RESOURCEID(IDR_A64_REG, "OUR ACAD 64bit CLSID");
	#else
		DECLARE_REGISTRY_APPID_RESOURCEID(IDR_A32_REG, "OUR ACAD 32bit CLSID");
	#endif
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The IDRs are resource IDs for the RGS file in a "REGISTRY" section of the resources.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We also needed this in our app class:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;// DllCanUnloadNow - Allows COM to unload DLL
#if !defined(_WIN32_WCE) &amp;amp;&amp;amp; !defined(_AMD64_) &amp;amp;&amp;amp; !defined(_IA64_)
	#pragma comment(linker, "/EXPORT:DllCanUnloadNow=_DllCanUnloadNow@0,PRIVATE")
	#pragma comment(linker, "/EXPORT:DllGetClassObject=_DllGetClassObject@12,PRIVATE")
	#pragma comment(linker, "/EXPORT:DllRegisterServer=_DllRegisterServer@0,PRIVATE")
	#pragma comment(linker, "/EXPORT:DllUnregisterServer=_DllUnregisterServer@0,PRIVATE")
#else
	#if defined(_X86_) || defined(_SHX_)
		#pragma comment(linker, "/EXPORT:DllCanUnloadNow=_DllCanUnloadNow,PRIVATE")
		#pragma comment(linker, "/EXPORT:DllGetClassObject=_DllGetClassObject,PRIVATE")
		#pragma comment(linker, "/EXPORT:DllRegisterServer=_DllRegisterServer,PRIVATE")
		#pragma comment(linker, "/EXPORT:DllUnregisterServer=_DllUnregisterServer,PRIVATE")
	#else
		#pragma comment(linker, "/EXPORT:DllCanUnloadNow,PRIVATE")
		#pragma comment(linker, "/EXPORT:DllGetClassObject,PRIVATE")
		#pragma comment(linker, "/EXPORT:DllRegisterServer,PRIVATE")
		#pragma comment(linker, "/EXPORT:DllUnregisterServer,PRIVATE")
	#endif // (_X86_)||(_SHX_)
#endif // !_WIN32_WCE &amp;amp;&amp;amp; !_AMD64_ &amp;amp;&amp;amp; !_IA64_&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And our registration functions look like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;extern OurModule _AtlModule; // &amp;lt;-- extern this in the .h file

OurModule _AtlModule;

//------------------------------------------------------------------------------
STDAPI DllCanUnloadNow()
//------------------------------------------------------------------------------
{
	if (_AtlModule.GetLockCount() &amp;gt; 0)
	{
		return S_FALSE;
	}
	return S_OK;
}

//------------------------------------------------------------------------------
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
//------------------------------------------------------------------------------
{
	// DllGetClassObject - Returns class factory
	if (S_OK == _AtlModule.GetClassObject(rclsid, riid, ppv))
	{
		return S_OK;
	}
	return AfxDllGetClassObject(rclsid, riid, ppv);
}

//typedef void (*OaEnablePerUserTLibRegistration)();

//------------------------------------------------------------------------------
STDAPI DllRegisterServer()
//------------------------------------------------------------------------------
{
	// DllRegisterServer - Adds entries to the system registry
	//HRESULT hr = ATL::AtlSetPerUserRegistration(true);
	HRESULT hRes1 = _AtlModule.UpdateRegistryAppId(TRUE);
	HINSTANCE hInstOle32 = NULL;
	try
	{
		HRESULT hr = _AtlModule.RegisterServer(TRUE);
		if (FAILED(hr))
		{
			hInstOle32 = LoadLibrary(_T("Oleaut32.dll"));
			if (hInstOle32 != NULL)
			{
				//OaEnablePerUserTLibRegistration lr = (OaEnablePerUserTLibRegistration)GetProcAddress(hInstOle32, ("OaEnablePerUserTLibRegistration"));
				ULONG (PASCAL *lr)();
				(FARPROC&amp;amp;)lr = GetProcAddress(hInstOle32, ("OaEnablePerUserTLibRegistration"));

				if (lr != NULL)
				{
					lr();
					hr = _AtlModule.RegisterServer(TRUE);
					if (SUCCEEDED(hr))
					{
						FreeLibrary(hInstOle32);
						return hr;
					}
				}

				HKEY hKCr;
				hr = RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\Classes"), 0, KEY_READ, &amp;amp;hKCr);
				if (hr != ERROR_SUCCESS)
				{
					return hr;
				}
				hr = RegOverridePredefKey(HKEY_CLASSES_ROOT, hKCr);
				if (FAILED(hr))
				{
					RegCloseKey(hKCr);
					return hr;
				}
				hr = _AtlModule.RegisterServer(TRUE);

				RegCloseKey(hKCr);

				RegOverridePredefKey(HKEY_CLASSES_ROOT, NULL);
				hr = S_OK;
			}
		}
		if (hInstOle32 != NULL)
		{
			FreeLibrary(hInstOle32);
		}
		return hr;
	}
	catch (...)
	{
		if (hInstOle32)
		{
			FreeLibrary(hInstOle32);
		}
		return E_FAIL;
	}
}

//------------------------------------------------------------------------------
STDAPI DllUnregisterServer()
//------------------------------------------------------------------------------
{
	// DllUnregisterServer - Removes entries from the system registry
	_AtlModule.UpdateRegistryAppId(FALSE);
	HRESULT hRes2 = _AtlModule.UnregisterServer(TRUE);
	return hRes2;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Feb 2025 20:37:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/com-property-registration/m-p/13339368#M8070</guid>
      <dc:creator>Kyudos</dc:creator>
      <dc:date>2025-02-25T20:37:18Z</dc:date>
    </item>
  </channel>
</rss>

