Back to index

lightning-sunbird  0.9+nobinonly
Functions
Registry.h File Reference
#include <objbase.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

HRESULT RegisterServerForPalmSync (const CLSID &clsid, const char *szFriendlyName, const char *szVerIndProgID, const char *szProgID)
HRESULT UnregisterServerForPalmSync (const CLSID &clsid, const char *szVerIndProgID, const char *szProgID)

Function Documentation

HRESULT RegisterServerForPalmSync ( const CLSID &  clsid,
const char *  szFriendlyName,
const char *  szVerIndProgID,
const char *  szProgID 
)

Definition at line 224 of file Registry.cpp.

{
    HMODULE hModule = GetModuleHandle(NULL);
    char szModuleName[MAX_SIZE];
    char szCLSID[CLSID_STRING_SIZE];

    nsCAutoString independentProgId(szVerIndProgID);
    nsCAutoString progId(szProgID);

    DWORD dwResult = ::GetModuleFileName(hModule, szModuleName,
                              sizeof(szModuleName)/sizeof(char));

    if (dwResult == 0)
        return S_FALSE;

    nsCAutoString moduleName(szModuleName);
    nsCAutoString registryKey("CLSID\\");

    moduleName += PALMSYNC_STARTUP_ARG;

    // Convert the CLSID into a char.

    if (!CLSIDtochar(clsid, szCLSID, sizeof(szCLSID)))
        return S_FALSE;
    registryKey += szCLSID;

    // Add the CLSID to the registry.
    if((!setKeyAndValue(registryKey, NULL, szFriendlyName))
         || (!setKeyAndValue(registryKey, "LocalServer32", moduleName.get()))
         // Add the ProgID subkey under the CLSID key.
         || (!setKeyAndValue(registryKey, "ProgID", szProgID))
         // Add the version-independent ProgID subkey under CLSID key.
         || (!setKeyAndValue(registryKey, "VersionIndependentProgID", szVerIndProgID))
         // Add the version-independent ProgID subkey under HKEY_CLASSES_ROOT.
         || (!setKeyAndValue(independentProgId, NULL, szFriendlyName))
         || (!setKeyAndValue(independentProgId, "CLSID", szCLSID))
         || (!setKeyAndValue(independentProgId, "CurVer", szProgID))
         // Add the versioned ProgID subkey under HKEY_CLASSES_ROOT.
         || (!setKeyAndValue(progId, NULL, szFriendlyName))
         || (!setKeyAndValue(progId, "CLSID", szCLSID))
      )
        return S_FALSE;

    RegisterProxy();

    return S_OK;
}

Here is the call graph for this function:

HRESULT UnregisterServerForPalmSync ( const CLSID &  clsid,
const char *  szVerIndProgID,
const char *  szProgID 
)

Definition at line 275 of file Registry.cpp.

{
    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;
}

Here is the call graph for this function: