Question about the getUserRegistryProductRootKey function

Question about the getUserRegistryProductRootKey function

7598165
Advocate Advocate
217 Views
0 Replies
Message 1 of 1

Question about the getUserRegistryProductRootKey function

7598165
Advocate
Advocate
int ArxGetProductKey()
{
#if (ADS > 18)
	const ACHAR* pRegKey = acdbHostApplicationServices()->getUserRegistryProductRootKey();
#else
	const ACHAR* pRegKey = acdbHostApplicationServices()->getRegistryProductRootKey();
#endif
	ads_retstr(pRegKey);
	adsout << "\nkey=" << pRegKey;
	return RSRSLT;
}

Including acdbHostApplicationServices()->getMachineRegistryProductRootKey();

The above function will retrieve a value such as:
"Software\\Autodesk\\AutoCAD\\R24.1\\ACAD-5101:409"



However, if I want to obtain the function pointer from within AcDb24.dll,

c:\Program Files\Autodesk\AutoCAD 2022>dumpbin /exports acdb24.dll | findstr RootKey
       9836 2660 001A5A14 ?getMachineRegistryProductRootKey@AcDbHostApplicationServices@@UEAAPEB_WXZ
      10512 2904 001A5A14 ?getUserRegistryProductRootKey@AcDbHostApplicationServices@@UEAAPEB_WXZ

 

typedef const ACHAR* (*PFN_getUserRegistryProductRootKey)();

const ACHAR* GetUserRegistryProductRootKey()
{
  const char* mangledName = "?getUserRegistryProductRootKey@AcDbHostApplicationServices@@UEAAPEB_WXZ";
    const wchar_t* dllName = L"ACDB24.dll";
    HMODULE hMod = GetModuleHandleW(dllName);
    if (!hMod) hMod = LoadLibraryW(dllName);
    if (!hMod) return nullptr;
    PFN_getUserRegistryProductRootKey pfnGetKey =
        (PFN_getUserRegistryProductRootKey)GetProcAddress(hMod, mangledName);
    if (!pfnGetKey) return nullptr;
    return pfnGetKey();
}

 

The result obtained from the above function is actually: SOFTWARE\Autodesk\ObjectDBX\R24.1

Why is the result different?


For the second method, what name mangling  should be used to get the correct value "Software\\Autodesk\\AutoCAD\\R24.1\\ACAD-5101:409"?




 
0 Likes
218 Views
0 Replies
Replies (0)