summaryrefslogtreecommitdiff
path: root/src/utilcode/regutil.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/utilcode/regutil.cpp')
-rw-r--r--src/utilcode/regutil.cpp697
1 files changed, 0 insertions, 697 deletions
diff --git a/src/utilcode/regutil.cpp b/src/utilcode/regutil.cpp
index d611ef965f..c38c38907a 100644
--- a/src/utilcode/regutil.cpp
+++ b/src/utilcode/regutil.cpp
@@ -111,19 +111,6 @@ LPWSTR REGUTIL::EnvGetString(LPCWSTR name, BOOL fPrependCOMPLUS)
#ifdef ALLOW_REGISTRY
-#ifndef FEATURE_CORECLR
-
-//*****************************************************************************
-// Gives the use the ability to turn on/off REGUTIL's ability to read from
-// the registry. This is useful in mscoree.dll on startup, in order to avoid
-// loading advapi32 and rpcrt4 until we're ready for them
-//*****************************************************************************
-void REGUTIL::AllowRegistryUse(BOOL fAllowUse)
-{
- s_fUseRegistry = fAllowUse;
-}// AllowRegistryUse
-
-#endif // !FEATURE_CORECLR
#endif // ALLOW_REGISTRY
@@ -522,690 +509,6 @@ DWORD REGUTIL::GetConfigFlag_DontUse_(LPCWSTR name, DWORD bitToSet, BOOL defValu
#ifdef ALLOW_REGISTRY
-#ifndef FEATURE_CORECLR
-
-//*****************************************************************************
-// Open's the given key and returns the value desired. If the key or value is
-// not found, then the default is returned.
-//*****************************************************************************
-long REGUTIL::GetLong( // Return value from registry or default.
- LPCTSTR szName, // Name of value to get.
- long iDefault, // Default value to return if not found.
- LPCTSTR szKey, // Name of key, NULL==default.
- HKEY hKeyVal) // What key to work on.
-{
- CONTRACTL
- {
- NOTHROW;
- GC_NOTRIGGER;
- FORBID_FAULT;
- SO_TOLERANT;
- }
- CONTRACTL_END;
-
- long iValue; // The value to read.
- DWORD iType; // Type of value to get.
- DWORD iSize; // Size of buffer.
- HKEY hKey; // Key for the registry entry.
-
- _ASSERTE(UseRegistry());
-
- FAULT_NOT_FATAL(); // We don't report OOM errors here, we return a default value.
-
- // Open the key if it is there.
- if (ERROR_SUCCESS != WszRegOpenKeyEx(hKeyVal, (szKey) ? szKey : FRAMEWORK_REGISTRY_KEY_W, 0, KEY_READ, &hKey))
- return (iDefault);
-
- // Read the key value if found.
- iType = REG_DWORD;
- iSize = sizeof(long);
- if (ERROR_SUCCESS != WszRegQueryValueEx(hKey, szName, NULL,
- &iType, (LPBYTE)&iValue, &iSize) || iType != REG_DWORD)
- iValue = iDefault;
-
- // We're done with the key now.
- VERIFY(!RegCloseKey(hKey));
- return (iValue);
-}
-
-
-// Opens or creates desired reg key, then writes iValue
-//*****************************************************************************
-long REGUTIL::SetOrCreateLong( // Return value from registry or default.
- LPCTSTR szName, // Name of value to get.
- long iValue, // Value to set.
- LPCTSTR szKey, // Name of key, NULL==default.
- HKEY hKeyVal) // What key to work on.
-{
- CONTRACTL
- {
- NOTHROW;
- GC_NOTRIGGER;
- }
- CONTRACTL_END;
-
- _ASSERTE(UseRegistry());
-
- long lRtn; // Return code.
- HKEY hKey; // Key for the registry entry.
-
-
- // Open the key if it is there, else create it
- if (WszRegCreateKeyEx(hKeyVal,
- (szKey) ? szKey : FRAMEWORK_REGISTRY_KEY_W,
- 0,
- NULL,
- REG_OPTION_NON_VOLATILE,
- KEY_WRITE,
- NULL,
- &hKey,
- NULL) != ERROR_SUCCESS)
- {
- return (-1);
- }
-
- // Read the key value if found.
- lRtn = WszRegSetValueEx(hKey, szName, NULL, REG_DWORD, (const BYTE *) &iValue, sizeof(DWORD));
-
- // We're done with the key now.
- VERIFY(!RegCloseKey(hKey));
- return (lRtn);
-}
-
-
-//*****************************************************************************
-// Open's the given key and returns the value desired. If the key or value is
-// not found, then the default is returned.
-//*****************************************************************************
-long REGUTIL::SetLong( // Return value from registry or default.
- LPCTSTR szName, // Name of value to get.
- long iValue, // Value to set.
- LPCTSTR szKey, // Name of key, NULL==default.
- HKEY hKeyVal) // What key to work on.
-{
- CONTRACTL
- {
- NOTHROW;
- GC_NOTRIGGER;
- }
- CONTRACTL_END;
-
- _ASSERTE(UseRegistry());
-
- long lRtn; // Return code.
- HKEY hKey; // Key for the registry entry.
-
- // Open the key if it is there.
- if (ERROR_SUCCESS != WszRegOpenKey(hKeyVal, (szKey) ? szKey : FRAMEWORK_REGISTRY_KEY_W, &hKey))
- return (-1);
-
- // Read the key value if found.
- lRtn = WszRegSetValueEx(hKey, szName, NULL, REG_DWORD, (const BYTE *) &iValue, sizeof(DWORD));
-
- // We're done with the key now.
- VERIFY(!RegCloseKey(hKey));
- return (lRtn);
-}
-
-//*****************************************************************************
-// Set an entry in the registry of the form:
-// HKEY_CLASSES_ROOT\szKey\szSubkey = szValue. If szSubkey or szValue are
-// NULL, omit them from the above expression.
-//*****************************************************************************
-BOOL REGUTIL::SetKeyAndValue( // TRUE or FALSE.
- LPCTSTR szKey, // Name of the reg key to set.
- LPCTSTR szSubkey, // Optional subkey of szKey.
- LPCTSTR szValue) // Optional value for szKey\szSubkey.
-{
- CONTRACTL
- {
- NOTHROW;
- GC_NOTRIGGER;
- }
- CONTRACTL_END;
-
- _ASSERTE(UseRegistry());
-
- size_t nLen = _tcslen(szKey) + 1;
- if (szSubkey)
- nLen += (_tcslen(szSubkey) + 1);
-
- NewArrayHolder<TCHAR> rcKey = new (nothrow) TCHAR[nLen]; // Buffer for the full key name.
- if (rcKey == NULL)
- return FALSE;
-
- HKEY hKey = NULL; // Handle to the new reg key.
-
- // Init the key with the base key name.
- _tcscpy_s(rcKey, nLen, szKey);
-
- // Append the subkey name (if there is one).
- if (szSubkey != NULL)
- {
- _tcscat_s(rcKey, nLen, _T("\\"));
- _tcscat_s(rcKey, nLen, szSubkey);
- }
-
- // Create the registration key.
- if (WszRegCreateKeyEx(HKEY_CLASSES_ROOT, rcKey, 0, NULL,
- REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
- &hKey, NULL) != ERROR_SUCCESS)
- return(FALSE);
-
- // Set the value (if there is one).
- if (szValue != NULL)
- if( WszRegSetValueEx(hKey, NULL, 0, REG_SZ, (BYTE *) szValue,
- (Wszlstrlen(szValue)+1) * sizeof(TCHAR)) != ERROR_SUCCESS ) {
- VERIFY(!RegCloseKey(hKey));
- return(FALSE);
- }
-
- VERIFY(!RegCloseKey(hKey));
- return(TRUE);
-}
-
-
-//*****************************************************************************
-// Delete an entry in the registry of the form:
-// HKEY_CLASSES_ROOT\szKey\szSubkey.
-//*****************************************************************************
-LONG REGUTIL::DeleteKey( // TRUE or FALSE.
- LPCTSTR szKey, // Name of the reg key to set.
- LPCTSTR szSubkey) // Subkey of szKey.
-{
- CONTRACTL
- {
- NOTHROW;
- GC_NOTRIGGER;
- }
- CONTRACTL_END;
-
- _ASSERTE(UseRegistry());
-
- size_t nLen = _tcslen(szKey) + 1;
- if (szSubkey)
- nLen += (_tcslen(szSubkey) + 1);
-
- NewArrayHolder<TCHAR> rcKey = new (nothrow) TCHAR[nLen]; // Buffer for the full key name.
- if (rcKey == NULL)
- return ERROR_NOT_ENOUGH_MEMORY;
-
- // Init the key with the base key name.
- _tcscpy_s(rcKey, nLen, szKey);
-
- // Append the subkey name (if there is one).
- if (szSubkey != NULL)
- {
- _tcscat_s(rcKey, nLen, _T("\\"));
- _tcscat_s(rcKey, nLen, szSubkey);
- }
-
- // Delete the registration key.
- return WszRegDeleteKey(HKEY_CLASSES_ROOT, rcKey);
-}
-
-
-//*****************************************************************************
-// Open the key, create a new keyword and value pair under it.
-//*****************************************************************************
-BOOL REGUTIL::SetRegValue( // Return status.
- LPCTSTR szKeyName, // Name of full key.
- LPCTSTR szKeyword, // Name of keyword.
- LPCTSTR szValue) // Value of keyword.
-{
- CONTRACTL
- {
- NOTHROW;
- GC_NOTRIGGER;
- }
- CONTRACTL_END;
-
- _ASSERTE(UseRegistry());
-
- HKEY hKey; // Handle to the new reg key.
-
- // Create the registration key.
- if (WszRegCreateKeyEx(HKEY_CLASSES_ROOT, szKeyName, 0, NULL,
- REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
- &hKey, NULL) != ERROR_SUCCESS)
- return (FALSE);
-
- // Set the value (if there is one).
- if (szValue != NULL)
- if( WszRegSetValueEx(hKey, szKeyword, 0, REG_SZ, (BYTE *)szValue,
- (Wszlstrlen(szValue)+1) * sizeof(TCHAR)) != ERROR_SUCCESS) {
- VERIFY(!RegCloseKey(hKey));
- return(FALSE);
- }
-
- VERIFY(!RegCloseKey(hKey));
- return (TRUE);
-}
-
-
-//*****************************************************************************
-// Does standard registration of a CoClass with a progid.
-//*****************************************************************************
-HRESULT REGUTIL::RegisterCOMClass( // Return code.
- REFCLSID rclsid, // Class ID.
- LPCTSTR szDesc, // Description of the class.
- LPCTSTR szProgIDPrefix, // Prefix for progid.
- int iVersion, // Version # for progid.
- LPCTSTR szClassProgID, // Class progid.
- LPCTSTR szThreadingModel, // What threading model to use.
- LPCTSTR szModule, // Path to class.
- HINSTANCE hInst, // Handle to module being registered
- LPCTSTR szAssemblyName, // Optional Assembly,
- LPCTSTR szVersion, // Optional Runtime version (directory containing runtime)
- BOOL fExternal, // flag - External to mscoree.
- BOOL fRelativePath) // flag - Relative path in szModule
-{
- CONTRACTL
- {
- NOTHROW;
- GC_NOTRIGGER;
- }
- CONTRACTL_END;
-
- WCHAR rcCLSID[256]; // CLSID\\szID.
- WCHAR rcInproc[_MAX_PATH+64]; // CLSID\\InprocServer32
- WCHAR rcProgID[256]; // szProgIDPrefix.szClassProgID
- WCHAR rcIndProgID[256]; // rcProgID.iVersion
- WCHAR rcShim[_MAX_PATH];
- HRESULT hr;
-
- // Format the prog ID values.
- VERIFY(_snwprintf_s(rcIndProgID, _countof(rcIndProgID), _TRUNCATE, W("%s.%s"), szProgIDPrefix, szClassProgID));
-
- VERIFY(_snwprintf_s(rcProgID, _countof(rcProgID), _TRUNCATE, W("%s.%d"), rcIndProgID, iVersion));
-
- // Do the initial portion.
- if (FAILED(hr = RegisterClassBase(rclsid, szDesc, rcProgID, rcIndProgID, rcCLSID, NumItems(rcCLSID))))
- return (hr);
-
- VERIFY(_snwprintf_s(rcInproc, _countof(rcInproc), _TRUNCATE, W("%s\\%s"), rcCLSID, W("InprocServer32")));
-
- if (!fExternal){
- SetKeyAndValue(rcCLSID, W("InprocServer32"), szModule);
- }
- else{
- LPCTSTR pSep = szModule;
- if (!fRelativePath && szModule) {
- pSep = wcsrchr(szModule, W('\\'));
- if(pSep == NULL)
- pSep = szModule;
- else
- pSep++;
- }
- HMODULE hMod = WszLoadLibrary(W("mscoree.dll"));
- if (!hMod)
- return E_FAIL;
-
- DWORD ret;
- VERIFY(ret = WszGetModuleFileName(hMod, rcShim, NumItems(rcShim)));
- FreeLibrary(hMod);
- if( !ret )
- return E_FAIL;
-
- // Set the server path.
- SetKeyAndValue(rcCLSID, W("InprocServer32"), rcShim);
- if(pSep)
- SetKeyAndValue(rcCLSID, W("Server"), pSep);
-
- if(szAssemblyName) {
- SetRegValue(rcInproc, W("Assembly"), szAssemblyName);
- SetRegValue(rcInproc, W("Class"), rcIndProgID);
- }
- }
-
- // Set the runtime version, it needs to be passed in from the outside
- if(szVersion != NULL) {
- LPCTSTR pSep2 = NULL;
- LPTSTR pSep1 = const_cast<LPTSTR>(wcsrchr(szVersion, W('\\')));
- if(pSep1 != NULL) {
- *pSep1 = '\0';
- pSep2 = wcsrchr(szVersion, W('\\'));
- if (!pSep2)
- pSep2 = szVersion;
- else
- pSep2 = pSep2++; // exclude '\\'
- }
- else
- pSep2 = szVersion;
-
- size_t bufLen = wcslen(rcInproc)+wcslen(pSep2)+2;
- WCHAR* rcVersion = new (nothrow) WCHAR[bufLen];
- if(rcVersion==NULL)
- return (E_OUTOFMEMORY);
- wcscpy_s(rcVersion, bufLen, rcInproc);
- wcscat_s(rcVersion, bufLen, W("\\"));
- wcscat_s(rcVersion, bufLen, pSep2);
- SetRegValue(rcVersion, W("ImplementedInThisVersion"), W(""));
- delete[] rcVersion;
-
- if(pSep1 != NULL)
- *pSep1 = W('\\');
- }
-
- // Add the threading model information.
- SetRegValue(rcInproc, W("ThreadingModel"), szThreadingModel);
- return (S_OK);
-}
-
-
-
-//*****************************************************************************
-// Does standard registration of a CoClass with a progid.
-// NOTE: This is the non-side-by-side execution version.
-//*****************************************************************************
-HRESULT REGUTIL::RegisterCOMClass( // Return code.
- REFCLSID rclsid, // Class ID.
- LPCTSTR szDesc, // Description of the class.
- LPCTSTR szProgIDPrefix, // Prefix for progid.
- int iVersion, // Version # for progid.
- LPCTSTR szClassProgID, // Class progid.
- LPCTSTR szThreadingModel, // What threading model to use.
- LPCTSTR szModule, // Path to class.
- BOOL bInprocServer) // Whether we register the server as inproc or local
-{
- CONTRACTL
- {
- NOTHROW;
- GC_NOTRIGGER;
- }
- CONTRACTL_END;
-
- WCHAR rcCLSID[256]; // CLSID\\szID.
- WCHAR rcInproc[_MAX_PATH+64]; // CLSID\\InprocServer32
- WCHAR rcProgID[256]; // szProgIDPrefix.szClassProgID
- WCHAR rcIndProgID[256]; // rcProgID.iVersion
- HRESULT hr;
-
- // Format the prog ID values.
- VERIFY(_snwprintf_s(rcIndProgID, _countof(rcIndProgID), _TRUNCATE, W("%s.%s"), szProgIDPrefix, szClassProgID));
-
- VERIFY(_snwprintf_s(rcProgID, _countof(rcProgID), _TRUNCATE, W("%s.%d"), rcIndProgID, iVersion));
-
- // Do the initial portion.
- if (FAILED(hr = RegisterClassBase(rclsid, szDesc, rcProgID, rcIndProgID, rcCLSID, NumItems(rcCLSID))))
- return (hr);
-
- WCHAR *szServerType = bInprocServer ? W("InprocServer32") : W("LocalServer32");
-
- // Set the server path.
- SetKeyAndValue(rcCLSID, szServerType , szModule);
-
- // Add the threading model information.
- VERIFY(_snwprintf_s(rcInproc, _countof(rcInproc), _TRUNCATE, W("%s\\%s"), rcCLSID, szServerType));
-
- SetRegValue(rcInproc, W("ThreadingModel"), szThreadingModel);
- return (S_OK);
-}
-
-
-
-//*****************************************************************************
-// Register the basics for a in proc server.
-//*****************************************************************************
-HRESULT REGUTIL::RegisterClassBase( // Return code.
- REFCLSID rclsid, // Class ID we are registering.
- LPCTSTR szDesc, // Class description.
- LPCTSTR szProgID, // Class prog ID.
- LPCTSTR szIndepProgID, // Class version independant prog ID.
- __out_ecount(cchOutCLSID) LPTSTR szOutCLSID, // CLSID formatted in character form.
- DWORD cchOutCLSID) // Out CLS ID buffer size
-{
- CONTRACTL
- {
- NOTHROW;
- GC_NOTRIGGER;
- }
- CONTRACTL_END;
-
- TCHAR szID[64]; // The class ID to register.
-
- // Create some base key strings.
- GuidToLPWSTR(rclsid, szID, NumItems(szID));
-
- size_t nLen = _tcslen(_T("CLSID\\")) + _tcslen( szID) + 1;
- if( cchOutCLSID < nLen )
- return E_INVALIDARG;
-
- _tcscpy_s(szOutCLSID, cchOutCLSID, W("CLSID\\"));
- _tcscat_s(szOutCLSID, cchOutCLSID, szID);
-
- // Create ProgID keys.
- SetKeyAndValue(szProgID, NULL, szDesc);
- SetKeyAndValue(szProgID, W("CLSID"), szID);
-
- // Create VersionIndependentProgID keys.
- SetKeyAndValue(szIndepProgID, NULL, szDesc);
- SetKeyAndValue(szIndepProgID, W("CurVer"), szProgID);
- SetKeyAndValue(szIndepProgID, W("CLSID"), szID);
-
- // Create entries under CLSID.
- SetKeyAndValue(szOutCLSID, NULL, szDesc);
- SetKeyAndValue(szOutCLSID, W("ProgID"), szProgID);
- SetKeyAndValue(szOutCLSID, W("VersionIndependentProgID"), szIndepProgID);
- SetKeyAndValue(szOutCLSID, W("NotInsertable"), NULL);
- return (S_OK);
-}
-
-
-
-//*****************************************************************************
-// Unregister the basic information in the system registry for a given object
-// class.
-//*****************************************************************************
-HRESULT REGUTIL::UnregisterCOMClass( // Return code.
- REFCLSID rclsid, // Class ID we are registering.
- LPCTSTR szProgIDPrefix, // Prefix for progid.
- int iVersion, // Version # for progid.
- LPCTSTR szClassProgID, // Class progid.
- BOOL fExternal) // flag - External to mscoree.
-{
- CONTRACTL
- {
- NOTHROW;
- GC_NOTRIGGER;
- }
- CONTRACTL_END;
-
- WCHAR rcCLSID[64]; // CLSID\\szID.
- WCHAR rcProgID[128]; // szProgIDPrefix.szClassProgID
- WCHAR rcIndProgID[128]; // rcProgID.iVersion
-
- // Format the prog ID values.
- VERIFY(_snwprintf_s(rcProgID, _countof(rcProgID), _TRUNCATE, W("%s.%s"), szProgIDPrefix, szClassProgID));
-
- VERIFY(_snwprintf_s(rcIndProgID, _countof(rcIndProgID), _TRUNCATE, W("%s.%d"), rcProgID, iVersion));
-
- UnregisterClassBase(rclsid, rcProgID, rcIndProgID, rcCLSID, NumItems(rcCLSID));
- DeleteKey(rcCLSID, W("InprocServer32"));
- if (fExternal){
- DeleteKey(rcCLSID, W("Server"));
- DeleteKey(rcCLSID, W("Version"));
- }
- GuidToLPWSTR(rclsid, rcCLSID, NumItems(rcCLSID));
- DeleteKey(W("CLSID"), rcCLSID);
- return (S_OK);
-}
-
-
-//*****************************************************************************
-// Unregister the basic information in the system registry for a given object
-// class.
-// NOTE: This is the non-side-by-side execution version.
-//*****************************************************************************
-HRESULT REGUTIL::UnregisterCOMClass( // Return code.
- REFCLSID rclsid, // Class ID we are registering.
- LPCTSTR szProgIDPrefix, // Prefix for progid.
- int iVersion, // Version # for progid.
- LPCTSTR szClassProgID) // Class progid.
-{
- CONTRACTL
- {
- NOTHROW;
- GC_NOTRIGGER;
- }
- CONTRACTL_END;
-
- WCHAR rcCLSID[64]; // CLSID\\szID.
- WCHAR rcProgID[128]; // szProgIDPrefix.szClassProgID
- WCHAR rcIndProgID[128]; // rcProgID.iVersion
-
- // Format the prog ID values.
- VERIFY(_snwprintf_s(rcProgID, _countof(rcProgID), _TRUNCATE, W("%s.%s"), szProgIDPrefix, szClassProgID));
-
- VERIFY(_snwprintf_s(rcIndProgID, _countof(rcIndProgID), _TRUNCATE, W("%s.%d"), rcProgID, iVersion));
-
- UnregisterClassBase(rclsid, rcProgID, rcIndProgID, rcCLSID, NumItems(rcCLSID));
- DeleteKey(rcCLSID, W("InprocServer32"));
- DeleteKey(rcCLSID, W("LocalServer32"));
-
- GuidToLPWSTR(rclsid, rcCLSID, NumItems(rcCLSID));
- DeleteKey(W("CLSID"), rcCLSID);
- return (S_OK);
-}
-
-
-//*****************************************************************************
-// Delete the basic settings for an inproc server.
-//*****************************************************************************
-HRESULT REGUTIL::UnregisterClassBase( // Return code.
- REFCLSID rclsid, // Class ID we are registering.
- LPCTSTR szProgID, // Class prog ID.
- LPCTSTR szIndepProgID, // Class version independant prog ID.
- __out_ecount(cchOutCLSID) LPTSTR szOutCLSID, // Return formatted class ID here.
- DWORD cchOutCLSID) // Out CLS ID buffer size
-{
- CONTRACTL
- {
- NOTHROW;
- GC_NOTRIGGER;
- }
- CONTRACTL_END;
-
- TCHAR szID[64]; // The class ID to register.
-
- // Create some base key strings.
- GuidToLPWSTR(rclsid, szID, NumItems(szID));
- size_t nLen = _tcslen(_T("CLSID\\")) + _tcslen( szID) + 1;
- if( cchOutCLSID < nLen )
- return E_INVALIDARG;
-
- _tcscpy_s(szOutCLSID, cchOutCLSID, W("CLSID\\"));
- _tcscat_s(szOutCLSID, cchOutCLSID, szID);
-
- // Delete the version independant prog ID settings.
- DeleteKey(szIndepProgID, W("CurVer"));
- DeleteKey(szIndepProgID, W("CLSID"));
- WszRegDeleteKey(HKEY_CLASSES_ROOT, szIndepProgID);
-
- // Delete the prog ID settings.
- DeleteKey(szProgID, W("CLSID"));
- WszRegDeleteKey(HKEY_CLASSES_ROOT, szProgID);
-
- // Delete the class ID settings.
- DeleteKey(szOutCLSID, W("ProgID"));
- DeleteKey(szOutCLSID, W("VersionIndependentProgID"));
- DeleteKey(szOutCLSID, W("NotInsertable"));
- WszRegDeleteKey(HKEY_CLASSES_ROOT, szOutCLSID);
- return (S_OK);
-}
-
-
-//*****************************************************************************
-// Register a type library.
-//*****************************************************************************
-HRESULT REGUTIL::RegisterTypeLib( // Return code.
- REFGUID rtlbid, // TypeLib ID we are registering.
- int iVersion, // Typelib version.
- LPCTSTR szDesc, // TypeLib description.
- LPCTSTR szModule) // Path to the typelib.
-{
- CONTRACTL
- {
- NOTHROW;
- GC_NOTRIGGER;
- }
- CONTRACTL_END;
-
- WCHAR szID[64]; // The typelib ID to register.
- WCHAR szTLBID[256]; // TypeLib\\szID.
- WCHAR szHelpDir[_MAX_PATH];
- WCHAR szDrive[_MAX_DRIVE] = {0};
- WCHAR szDir[_MAX_DIR] = {0};
- WCHAR szVersion[64];
- LPWSTR szTmp;
-
- // Create some base key strings.
- GuidToLPWSTR(rtlbid, szID, NumItems(szID));
-
- _tcscpy_s(szTLBID, _countof(szTLBID), W("TypeLib\\"));
- _tcscat_s(szTLBID, _countof(szTLBID), szID);
-
- VERIFY(_snwprintf_s(szVersion, _countof(szVersion), _TRUNCATE, W("%d.0"), iVersion));
-
- // Create Typelib keys.
- SetKeyAndValue(szTLBID, NULL, NULL);
- SetKeyAndValue(szTLBID, szVersion, szDesc);
- _tcscat_s(szTLBID, _countof(szTLBID), W("\\"));
- _tcscat_s(szTLBID, _countof(szTLBID), szVersion);
- SetKeyAndValue(szTLBID, W("0"), NULL);
- SetKeyAndValue(szTLBID, W("0\\win32"), szModule);
- SetKeyAndValue(szTLBID, W("FLAGS"), W("0"));
- SplitPath(szModule, szDrive, _MAX_DRIVE, szDir, _MAX_DIR, NULL, 0, NULL, 0);
- _tcscpy_s(szHelpDir, _countof(szHelpDir), szDrive);
- if ((szTmp = CharPrev(szDir, szDir + Wszlstrlen(szDir))) != NULL)
- *szTmp = '\0';
- _tcscat_s(szHelpDir, _countof(szHelpDir), szDir);
- SetKeyAndValue(szTLBID, W("HELPDIR"), szHelpDir);
- return (S_OK);
-}
-
-
-//*****************************************************************************
-// Remove the registry keys for a type library.
-//*****************************************************************************
-HRESULT REGUTIL::UnregisterTypeLib( // Return code.
- REFGUID rtlbid, // TypeLib ID we are registering.
- int iVersion) // Typelib version.
-{
- CONTRACTL
- {
- NOTHROW;
- GC_NOTRIGGER;
- }
- CONTRACTL_END;
-
- WCHAR szID[64]; // The typelib ID to register.
- WCHAR szTLBID[256]; // TypeLib\\szID.
- WCHAR szTLBVersion[256]; // TypeLib\\szID\\szVersion
- WCHAR szVersion[64];
-
- // Create some base key strings.
- GuidToLPWSTR(rtlbid, szID, NumItems(szID));
-
- VERIFY(_snwprintf_s(szVersion, _countof(szVersion), _TRUNCATE, W("%d.0"), iVersion));
-
- _tcscpy_s(szTLBID, _countof(szTLBID), W("TypeLib\\"));
- _tcscat_s(szTLBID, _countof(szTLBID), szID);
- _tcscpy_s(szTLBVersion, _countof(szTLBVersion), szTLBID);
- _tcscat_s(szTLBVersion, _countof(szTLBVersion), W("\\"));
- _tcscat_s(szTLBVersion, _countof(szTLBVersion), szVersion);
-
- // Delete Typelib keys.
- DeleteKey(szTLBVersion, W("HELPDIR"));
- DeleteKey(szTLBVersion, W("FLAGS"));
- DeleteKey(szTLBVersion, W("0\\win32"));
- DeleteKey(szTLBVersion, W("0"));
- DeleteKey(szTLBID, szVersion);
- WszRegDeleteKey(HKEY_CLASSES_ROOT, szTLBID);
- return (0);
-}
-
-#endif // !FEATURE_CORECLR
//