STDAPI DllUnregisterServer()
{
	unregisterFactory( CLSID_MackieControlXT );
	unregisterFactory( CLSID_MackieControlXTPropPage );
	unregisterFactory( CLSID_MackieControlMaster );
	unregisterFactory( CLSID_MackieControlMasterPropPage );
	unregisterFactory( CLSID_MackieControlC4 );
	unregisterFactory( CLSID_MackieControlC4PropPage );

	// Remove the CLSID from HKEY_CLASSES_ROOT\CakewalkControlSurfaces
	char szCLSID[ 128 ];
	char szKey[ 256 ];

	CLSIDToString( CLSID_MackieControlXT, szCLSID, sizeof szCLSID );
	strlcpy( szKey, "CakewalkControlSurfaces\\", sizeof(szKey) );
	strlcat( szKey, szCLSID, sizeof(szKey) );
	recursiveDeleteKey( HKEY_CLASSES_ROOT, szKey );

	CLSIDToString( CLSID_MackieControlMaster, szCLSID, sizeof szCLSID );
	strlcpy( szKey, "CakewalkControlSurfaces\\", sizeof(szKey) );
	strlcat( szKey, szCLSID, sizeof(szKey) );
	recursiveDeleteKey( HKEY_CLASSES_ROOT, szKey );

	CLSIDToString( CLSID_MackieControlC4, szCLSID, sizeof szCLSID );
	strlcpy( szKey, "CakewalkControlSurfaces\\", sizeof(szKey) );
	strlcat( szKey, szCLSID, sizeof(szKey) );
	recursiveDeleteKey( HKEY_CLASSES_ROOT, szKey );

	return S_OK;
}
// Remove the component from the registry.
LONG UnregisterServer(REFCLSID clsid,             // Class ID
                      const char* szVerIndProgID, // Programmatic
                      const char* szProgID)       // IDs
{
	// Convert the CLSID into a char.
	char szCLSID[CLSID_STRING_SIZE];
	CLSIDtochar(clsid, szCLSID, sizeof(szCLSID));

	// Build the key CLSID\\{...}
	char szKey[64];
	strcpy(szKey, "CLSID\\");
	strcat(szKey, szCLSID);

	// Delete the CLSID Key - CLSID\{...}
	LONG lResult = recursiveDeleteKey(HKEY_CLASSES_ROOT, szKey);
	assert((lResult == ERROR_SUCCESS) || (lResult == ERROR_FILE_NOT_FOUND)); // Subkey may not exist.

	// Delete the version-independent ProgID Key.
	lResult = recursiveDeleteKey(HKEY_CLASSES_ROOT, szVerIndProgID);
	assert((lResult == ERROR_SUCCESS) || (lResult == ERROR_FILE_NOT_FOUND)); // Subkey may not exist.

	// Delete the ProgID key.
	lResult = recursiveDeleteKey(HKEY_CLASSES_ROOT, szProgID);
	assert((lResult == ERROR_SUCCESS) || (lResult == ERROR_FILE_NOT_FOUND)); // Subkey may not exist.

	return S_OK;
}
Beispiel #3
0
//
// Remove the component from the registry.
//
LONG UnregisterServer(const CLSID& clsid,         // Class ID
                      const char* szVerIndProgID, // Programmatic
                      const char* szProgID)       //   IDs
{
	// Convert the CLSID into a char.
	char szCLSID[GUID_STRING_SIZE] ;
	GUIDtochar(clsid, szCLSID, sizeof(szCLSID)) ;

	// Build the key CLSID\\{...}
	char szKey[80] ;
	strcpy(szKey, "CLSID\\") ;
	strcat(szKey, szCLSID) ;

	// Check for a another server for this component.
#ifdef _OUTPROC_SERVER_
	if (SubkeyExists(szKey, "InprocServer32"))
#else
	if (SubkeyExists(szKey, "LocalServer32"))
#endif
	{
		// Delete only the path for this server.
#ifdef _OUTPROC_SERVER_
		strcat(szKey, "\\LocalServer32") ;
#else
		strcat(szKey, "\\InprocServer32") ;
#endif
		LONG lResult = recursiveDeleteKey(HKEY_CLASSES_ROOT, szKey) ;
		assert(lResult == ERROR_SUCCESS) ;
	}
	else
	{
		// Delete all related keys.
		// Delete the CLSID Key - CLSID\{...}
		LONG lResult = recursiveDeleteKey(HKEY_CLASSES_ROOT, szKey) ;
		assert((lResult == ERROR_SUCCESS) ||
		       (lResult == ERROR_FILE_NOT_FOUND)) ; // Subkey may not exist.

		// Delete the version-independent ProgID Key.
		lResult = recursiveDeleteKey(HKEY_CLASSES_ROOT, szVerIndProgID) ;
		assert((lResult == ERROR_SUCCESS) ||
		       (lResult == ERROR_FILE_NOT_FOUND)) ; // Subkey may not exist.

		// Delete the ProgID key.
		lResult = recursiveDeleteKey(HKEY_CLASSES_ROOT, szProgID) ;
		assert((lResult == ERROR_SUCCESS) ||
		       (lResult == ERROR_FILE_NOT_FOUND)) ; // Subkey may not exist.
	}
	return S_OK ;
}
// Delete a key and all of its descendents.
LONG recursiveDeleteKey(HKEY hKeyParent,           // Parent of key to delete
                        const char* lpszKeyChild)  // Key to delete
{
	// Open the child.
	HKEY hKeyChild;
	LONG lRes = RegOpenKeyEx(hKeyParent, lpszKeyChild, 0, KEY_ALL_ACCESS, &hKeyChild);
	if(lRes != ERROR_SUCCESS)
		return lRes;

	// Enumerate all of the decendents of this child.
	FILETIME time;
	char szBuffer[256];
	DWORD dwSize = 256;
	while(RegEnumKeyEx(hKeyChild, 0, szBuffer, &dwSize, NULL, NULL, NULL, &time) == S_OK)
	{
		// Delete the decendents of this child.
		lRes = recursiveDeleteKey(hKeyChild, szBuffer);
		if(lRes != ERROR_SUCCESS)
		{
			// Cleanup before exiting.
			RegCloseKey(hKeyChild);
			return lRes;
		}
		dwSize = 256;
	}

	// Close the child.
	RegCloseKey(hKeyChild);

	// Delete this child.
	return RegDeleteKey(hKeyParent, lpszKeyChild);
}
Beispiel #5
0
void UnregisterInterface(const IID &iid)
{
	char szIID[CLSID_STRING_SIZE] ;
	CLSIDtochar(iid, szIID, sizeof(szIID)) ;

	// Build the key Interface\\{...}
	char szKey[64] ;
	strcpy(szKey, "Interface\\") ;
	strcat(szKey, szIID) ;

	LONG lResult = recursiveDeleteKey(HKEY_CLASSES_ROOT, szKey) ;
}
Beispiel #6
0
LONG UnregisterServer(const CLSID& clsid,         // Class ID
                      const char* szVerIndProgID, // Programmatic
                      const char* szProgID)       //   IDs
{
    LONG lResult = S_OK;

    // Convert the CLSID into a char.

    char szCLSID[CLSID_STRING_SIZE];
    if (!CLSIDtochar(clsid, szCLSID, sizeof(szCLSID)))
        return S_FALSE;

    UnRegisterProxy();

    nsCAutoString registryKey("CLSID\\");
    registryKey += szCLSID;

    lResult = recursiveDeleteKey(HKEY_CLASSES_ROOT, registryKey.get());
    if (lResult == ERROR_SUCCESS || lResult == ERROR_FILE_NOT_FOUND)
        return lResult;

    registryKey += "\\LocalServer32";

    // Delete only the path for this server.

    lResult = recursiveDeleteKey(HKEY_CLASSES_ROOT, registryKey.get());
    if (lResult != ERROR_SUCCESS && lResult != ERROR_FILE_NOT_FOUND)
        return lResult;

    // Delete the version-independent ProgID Key.
    lResult = recursiveDeleteKey(HKEY_CLASSES_ROOT, szVerIndProgID);
    if (lResult != ERROR_SUCCESS && lResult != ERROR_FILE_NOT_FOUND)
        return lResult;

    lResult = recursiveDeleteKey(HKEY_CLASSES_ROOT, szProgID);

    return lResult;
}
static void unregisterFactory( const CLSID& clsid )
{
	// Get server location.
	char szModule[ _MAX_PATH ];
	::GetModuleFileName( theApp.m_hInstance, szModule, sizeof szModule );

	// Convert the CLSID into a char.
	char szCLSID[ 128 ];
	CLSIDToString( clsid, szCLSID, sizeof szCLSID );

	char szKey[ 64 ];
	strlcpy( szKey, "CLSID\\", sizeof(szKey) );
	strlcat( szKey, szCLSID, sizeof(szKey) );

	recursiveDeleteKey( HKEY_CLASSES_ROOT, szKey );
}
static void recursiveDeleteKey( HKEY hKeyParent, const char* pcszKeyChild )
{
	// Open the child.
	HKEY hKeyChild;
	if (ERROR_SUCCESS == RegOpenKeyEx( hKeyParent, pcszKeyChild, 0, KEY_ALL_ACCESS, &hKeyChild ))
	{
		// Enumerate all of the decendents of this child.
		FILETIME time;
		char szBuffer[ 256 ];
		DWORD dwSize = sizeof szBuffer;
		while (S_OK == RegEnumKeyEx( hKeyChild, 0, szBuffer, &dwSize, NULL, NULL, NULL, &time ))
		{
			// Delete the decendents of this child.
			recursiveDeleteKey( hKeyChild, szBuffer );
			dwSize = sizeof szBuffer;
		}

		// Close the child.
		RegCloseKey( hKeyChild );
	}

	// Delete this child.
	RegDeleteKey( hKeyParent, pcszKeyChild );
}
Beispiel #9
0
//
// Add entry to the registry about CLSID object
//
void MultiVMRRegisterClass(
                           const CLSID& clsid,
                           TCHAR *achClassName,
                           BOOL bRegister)
{
    HRESULT hr = S_OK;
    TCHAR achModule[MAX_PATH];
    WCHAR wcModule[MAX_PATH];
    WCHAR wcKey[MAX_PATH];
    TCHAR achKey[MAX_PATH];
    TCHAR achThreadingModel[] = TEXT("Both");
    long err = 0;
    LPOLESTR wcCLSID = NULL;
    HKEY hKey = NULL;
    HKEY hSubKey = NULL;

    GetModuleFileName( g_hInst, achModule, sizeof(achModule) );

#ifdef UNICODE
    StringCchCopyW( wcModule, NUMELMS(wcModule), achModule );
#else
    MultiByteToWideChar(CP_ACP, 0, achModule, -1, wcModule, MAX_PATH);
#endif

    hr = StringFromCLSID(clsid, &wcCLSID);

    hr = StringCchPrintfW(wcKey, NUMELMS(wcKey), L"CLSID\\%s", wcCLSID);

#ifdef UNICODE
    hr = StringCchCopy( achKey, NUMELMS(achKey), wcKey);
#else
    WideCharToMultiByte(CP_ACP, 0, wcKey, -1, achKey, MAX_PATH, 0, 0);
#endif

    // first, delete wcKey if it exists
    err = recursiveDeleteKey( HKEY_CLASSES_ROOT, achKey);

    if( bRegister )
    {
        // create new key
        err = RegCreateKeyEx(   HKEY_CLASSES_ROOT,
                                achKey,
                                NULL,
                                NULL,
                                REG_OPTION_NON_VOLATILE,
                                KEY_ALL_ACCESS,
                                NULL,
                                &hKey,
                                NULL);
        if (ERROR_SUCCESS == err)
        {
            err = RegSetValueEx( hKey, NULL, 0, REG_SZ,(BYTE *)achClassName,
                                    sizeof(TCHAR) * ( lstrlen(achClassName)+1));
            err = RegCreateKeyEx(   hKey,
                                    TEXT("InprocServer32"),
                                    NULL,
                                    NULL,
                                    REG_OPTION_NON_VOLATILE,
                                    KEY_ALL_ACCESS,
                                    NULL,
                                    &hSubKey,
                                    NULL);
            if( ERROR_SUCCESS == err)
            {
                err = RegSetValueEx( hSubKey, NULL, 0, REG_SZ,(BYTE *)achModule,
                                    sizeof(TCHAR) * ( lstrlen(achModule)+1));
                err = RegSetValueEx( hSubKey, TEXT("ThreadingModel"), 0, REG_SZ,(BYTE *)achThreadingModel,
                                    sizeof(TCHAR) * ( lstrlen(achThreadingModel)+1));
                RegCloseKey( hSubKey );
            }
            RegCloseKey( hKey );
        }
    }
    CoTaskMemFree(wcCLSID);
}