Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions
nsInstallBitwise.cpp File Reference
#include "nscore.h"
#include "nsInstall.h"
#include "prmem.h"
#include "nsInstallBitwise.h"

Go to the source code of this file.

Defines

#define KEY_SHARED_DLLS   "Software\\Microsoft\\Windows\\CurrentVersion\\SharedDlls"

Functions

PRInt32 RegisterSharedFile (const char *file, PRBool bAlreadyExists)

Define Documentation

#define KEY_SHARED_DLLS   "Software\\Microsoft\\Windows\\CurrentVersion\\SharedDlls"

Definition at line 50 of file nsInstallBitwise.cpp.


Function Documentation

PRInt32 RegisterSharedFile ( const char *  file,
PRBool  bAlreadyExists 
)

Definition at line 52 of file nsInstallBitwise.cpp.

{
  PRInt32 rv = nsInstall::SUCCESS;

#ifdef WIN32
  HKEY     root;
  HKEY     keyHandle = 0;
  LONG     result;
  DWORD    type = REG_DWORD;
  DWORD    dwDisposition;
  PRUint32 valbuf = 0;
  PRUint32 valbufsize;

  valbufsize = sizeof(PRUint32);
  root       = HKEY_LOCAL_MACHINE;
  result     = RegCreateKeyEx(root, KEY_SHARED_DLLS, 0, nsnull, REG_OPTION_NON_VOLATILE, KEY_READ | KEY_WRITE, nsnull, &keyHandle, &dwDisposition);
  if(ERROR_SUCCESS == result)
  {
    result = RegQueryValueEx(keyHandle, file, nsnull, &type, (LPBYTE)&valbuf, (LPDWORD)&valbufsize);

    if((ERROR_SUCCESS == result) && (type == REG_DWORD))
      ++valbuf;
    else
    {
      valbuf = 1;
      if(bAlreadyExists == PR_TRUE)
        ++valbuf;
    }

    RegSetValueEx(keyHandle, file, 0, REG_DWORD, (LPBYTE)&valbuf, valbufsize);
    RegCloseKey(keyHandle);
  }
  else
    rv = nsInstall::UNEXPECTED_ERROR;

#endif

  return(rv);
}

Here is the caller graph for this function: