Subversion Repositories libraries.mycontrols

Rev

Rev 1 | Blame | Compare with Previous | Last modification | View Log

/*
Module : HKLM.H
Purpose: Interface for a class to provide simple
         access to the HKEY_LOCAL_MACHINE\Software\Company\MyApp
                 registry key similiar to the functions MFC provides
                 to access the same settings in HKEY_CURRENT_USER
Created: PJN / 27-07-1998



Copyright (c) 1998 - 2001 by PJ Naughter.  (Web: www.naughter.com, Email: pjna@naughter.com)

All rights reserved.

Copyright / Usage Details:

You are allowed to include the source code in any product (commercial, shareware, freeware or otherwise) 
when your product is released in binary form. You are allowed to modify the source code in any way you want 
except you cannot modify the copyright details at the top of each module. If you want to distribute source 
code with your application, then you are only allowed to distribute versions released by the author. This is 
to maintain a single distribution point for the source code. 

*/

#ifndef __HKLM_H__
#define __HKLM_H__


class CHKLM
{
public:
  //Perform the same job as the function of the same name
    // in the CWinApp class in MFC
  void SetRegistryKey(char *lpszRegistryKey);
  void SetRegistryKey(UINT nIDRegistryKey);

  //Allows you to customize the "Product Name" registry key. If you do not
  //call SetAppRegistryKey, then "AfxGetApp()->m_pszAppName" is
  //used by default
  void SetProductNameRegistryKey(LPCTSTR lpszProductNameRegistryKey);
  void SetProductNameRegistryKey(UINT nIDProductNameRegistryKey);
  CString GetProductNameRegistryKey() const;

    //Allows saving and restoring of a profile settings to the 
    //HKEY_LOCAL_MACHINE\Software\"Company Name"\"Product Name"
    //registry key. These classes are modelled upon the functions
    //of the same name in the CWinApp class in MFC
    BOOL    WriteProfileString(LPCTSTR lpszSection, LPCTSTR lpszEntry, LPCTSTR lpszValue);
    BOOL    WriteProfileInt(LPCTSTR lpszSection, LPCTSTR lpszEntry, int nValue);
    CString GetProfileString(LPCTSTR lpszSection, LPCTSTR lpszEntry, LPCTSTR lpszDefault = NULL);
    UINT    GetProfileInt(LPCTSTR lpszSection, LPCTSTR lpszEntry, int nDefault);
    BOOL    GetProfileBinary(LPCTSTR lpszSection, LPCTSTR lpszEntry, LPBYTE* ppData, UINT* pBytes);
    BOOL    WriteProfileBinary(LPCTSTR lpszSection, LPCTSTR lpszEntry, LPBYTE pData, UINT nBytes);
  BOOL    GetProfileStringArray(LPCTSTR lpszSection, LPCTSTR lpszEntry, CStringArray& array);
  BOOL    WriteProfileStringArray(LPCTSTR lpszSection, LPCTSTR lpszEntry, const CStringArray& array);

protected:
//Misc functions
    HKEY GetAppRegistryKey(BOOL bReadOnly = FALSE);
    HKEY GetSectionKey(LPCTSTR lpszSection, BOOL bReadOnly = FALSE);
  BOOL GetStringArrayFromRegistry(HKEY hKey, LPCTSTR lpszEntry, CStringArray& array);
  BOOL SetStringArrayIntoRegistry(HKEY hKey, LPCTSTR lpszEntry, const CStringArray& array);

//Member variables
    CString m_sRegistryKey;
  CString m_sProductNameRegistryKey;
};



#endif //__HKLM_H__