Titus Information Systems, Inc.

Standard Library
CRegistry Class

An instance of this class is used by an application to access the system registry.  The following public member functions are provided to create, set, and access registry keys of all types:

CRegistry::CRegistry()
This is the default constructor.  It initializes the data members to NULL.
CRegistry::CRegistry(HKEY Root)
This constructor initializes the data members to NULL and sets the root of registry access to Root, which should be either HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE.
CRegistry::~CRegistry()
This is the destructor.  It releases all allocated data members.
void CRegistry::SetRoot(HKEY Root)
This member function sets the root of registry access to Root, which should be either HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE.
BOOL CRegistry::OpenPath(CString Path, BOOL DisplayError = TRUE)
This member function opens the registry path specified in the root set by the constructor or a call to CRegistry::SetRoot().  If the path cannot be opened, the function returns FALSE, and, if DisplayError is TRUE, a MessageBox error is displayed.
BOOL CRegistry::CreatePath(CString Path, BOOL DisplayError = TRUE)
This member function creates and opens the registry path specified in the root set by the constructor or a call to CRegistry::SetRoot().  If the path cannot be created, the function returns FALSE, and, if DisplayError is TRUE, a MessageBox error is displayed.
void CRegistry::ClosePath()
This member function closes the registry path opened by a call to CRegistry::OpenPath() or CRegistry::CreatePath().
BOOL CRegistry::NextKey(CString&Key)
This member function returns in Key the next key in the registry path opened by a call to CRegistry::OpenPath().  The function returns FALSE if there are no more keys in the path or there is an error accessing the path.  If there is an error, a MessageBox error is displayed.
BOOL CRegistry::OpenKey(CString Key, BOOL DisplayError = TRUE, BOOL AllAccess = TRUE)
This member function opens the specified Key in the registry path opened by a call to CRegistry::OpenPath().  If AllAccess is TRUE, access is set to KEY_ALL_ACCESS; otherwise access is set to KEY_QUERY_VALUE.  If Key cannot be accessed, the function returns FALSE, and, if DisplayError is TRUE, a MessageBox error is displayed.
void CRegistry::CloseKey()
This member function closes the registry key opened by CRegistry::OpenKey().
BOOL CRegistry::GetValue(CString Value, CString&Data)
BOOL CRegistry::GetValue(CString Value, BYTE*Data, DWORD*Size)
These member functions return the data stored in the specified Value for the registry key opened by CRegistry::OpenKey().  If Value cannot be accessed, the function returns FALSE, and a MessageBox error is displayed.
BOOL CRegistry::NextValue(CString&Value, CString&Data)
This member function returns in Value the next value in the registry key opened by a call to CRegistry::OpenKey().  If the value is accessed, the data in that value will also be returned in Data.  The function returns FALSE if there are no more values in the key or there is an error accessing the key.  If there is an error, a MessageBox error is displayed.
BOOL CRegistry::OpenUserShell(BOOL DisplayError = TRUE)
This member function opens the "Shell Folders" key in the registry for the "Current User" with query access.  If the key cannot be accessed, the function returns FALSE, and, if DisplayError is TRUE, a MessageBox error is displayed.
BOOL CRegistry::GetUserShell(CString Value, CString&Data)
This member function return the data stored in the specified Value for the "Shell Folders" registry key opened by CRegistry::OpenUserShell().  If Value cannot be accessed, the function returns FALSE, and a MessageBox error is displayed.
void CRegistry::CloseUserShell()
This member function closes the "Shell Folders" registry key opened by CRegistry::OpenUserShell().
BOOL CRegistry::OpenCommonShell(BOOL DisplayError = TRUE)
This member function opens the "Shell Folders" key in the registry for the "Local Machine" with query access.  If the key cannot be accessed, the function returns FALSE, and, if DisplayError is TRUE, a MessageBox error is displayed.
BOOL CRegistry::GetCommonShell(CString Value, CString&Data)
This member function return the data stored in the specified Value for the "Shell Folders" registry key opened by CRegistry::OpenCommonShell().  If Value cannot be accessed, the function returns FALSE, and a MessageBox error is displayed.
void CRegistry::CloseCommonShell()
This member function closes the "Shell Folders" registry key opened by CRegistry::OpenCommonShell().
BOOL CRegistry::SetEventLog(CString Type, CString Application, CString Path, DWORD Supported)
This member function creates or updates the Event Log entry in the registry for the specified Application in the Event Log Type.  Types are Application, Security, or System.  Specify in Path the executable module that contains the Event Log code interpretation strings.  Specify in Supported the types of Event Log entries that are supported by your application.  If the Event Log registry key cannot be accessed, the function returns FALSE, and a MessageBox error is displayed.
BOOL CRegistry::DeleteEventLog(CString Type, CString Application)
This member function removes the Event Log entry in the registry for the specified Application in the Event Log Type.  If the Event Log registry key cannot be accessed, the function returns FALSE, and a MessageBox error is displayed.
BOOL CRegistry::OpenApplication(CString Company, CString Application, BOOL DisplayError = TRUE)
This member function opens the "Current User" registry Application key for Company with all access.  If the key cannot be accessed, the function returns FALSE, and, if DisplayError is TRUE, a MessageBox error is displayed.
BOOL CRegistry::GetApplication(CString Value, CString&Result)
BOOL CRegistry::GetApplication(CString Value, DWORD*Result)
BOOL CRegistry::GetApplication(CString Value, LONG*Result)
BOOL CRegistry::GetApplication(CString Value, BYTE*Result, DWORD Len = 1)
BOOL CRegistry::GetApplication(CString Value, BOOL*Result)
These member functions return the data stored in the specified Value for the "Current User" registry Application key for Company that was opened by CRegistry::OpenApplication().  If Value cannot be accessed, the function returns FALSE, and a MessageBox error is displayed.
BOOL CRegistry::SetApplication(CString Value, CString Value)
BOOL CRegistry::SetApplication(CString Value, DWORD Value)
BOOL CRegistry::SetApplication(CString Value, LONG Value)
BOOL CRegistry::SetApplication(CString Value, BYTE*Value, DWORD Len = 1)
BOOL CRegistry::SetApplication(CString Value, BOOL Value)
These member functions create or update the data stored in the specified Value for the "Current User" registry Application key for Company that was opened by CRegistry::OpenApplication().  If Value cannot be accessed, the function returns FALSE, and a MessageBox error is displayed.
BOOL CRegistry::DeleteApplication(CString Value)
This member function removes the specified Value for the "Current User" registry Application key for Company that was opened by CRegistry::OpenApplication().  If Value cannot be accessed, the function returns FALSE, and a MessageBox error is displayed.
void CRegistry::CloseApplication()
This member function closes the "Current User" registry Application key for Company that was opened by CRegistry::OpenApplication().
BOOL CRegistry::DeleteApplication(CString Company, CString Application, BOOL Empty)
This member function removes all the values for the "Current User" registry Application key for Company and removes the Application key.  If Empty is TRUE, and the Company key is empty, the Company key is removed as well.  If any key or value cannot be removed, the function returns FALSE, and a MessageBox error is displayed.
BOOL CRegistry::SetAutoLogon()
This member function sets the "Auto Logon" key in the registry so that, the next time the computer is started, it will be automatically logged on to the current user.  For this to properly function, the current user must have a blank password.
BOOL CRegistry::OpenFont(BOOL DisplayError = TRUE)
This member function opens the "Fonts" key in the registry for the "Local Machine" with all access.  If the key cannot be accessed, the function returns FALSE, and, if DisplayError is TRUE, a MessageBox error is displayed.
BOOL CRegistry::SetFont(CString Font, CString File)
This member function "installs" the specified Font in the "Fonts" registry key opened by CRegistry::OpenFont().  The font must be contained in the specified File.  If File cannot be located or the "Fonts" registry key cannot be accessed, the function returns FALSE, and a MessageBox error is displayed.
BOOL CRegistry::DeleteFont(CString Font)
This member function deletes the specified Font in the "Fonts" registry key opened by CRegistry::OpenFont().  If the "Fonts" registry key cannot be accessed, the function returns FALSE, and a MessageBox error is displayed.
BOOL CRegistry::CloseFont()
This member function closes the "Fonts" registry key opened by CRegistry::OpenFont().
BOOL CRegistry::OpenEnvironment(BOOL DisplayError = TRUE)
This member function opens the "Environment" key in the registry for the "Current User" with all access.  If the key cannot be accessed, the function returns FALSE, and, if DisplayError is TRUE, a MessageBox error is displayed.
BOOL CRegistry::GetEnvironment(CString Key, CString&Result)
This member function returns in Result the value of the specified Key from the associated value in the "Environment" registry key opened by CRegistry::OpenEnvironment().  If the "Environment" registry key cannot be accessed, the function returns FALSE, and a MessageBox error is displayed.
BOOL CRegistry::SetEnvironment(CString Key, CString Value)
This member function sets the specified Key to the specified Value in associated value in the "Environment" registry key opened by CRegistry::OpenEnvironment().  If the "Environment" registry key cannot be accessed, the function returns FALSE, and a MessageBox error is displayed.
BOOL CRegistry::DeleteEnvironment(CString Key)
This member function removes the value associated with the specified Key from the "Environment" registry key opened by CRegistry::OpenEnvironment().  If the "Environment" registry key cannot be accessed, the function returns FALSE, and a MessageBox error is displayed.
BOOL CRegistry::AddEnvironment(CString Key, CString Value)
This member function updates the associated value for the specified Key in the "Environment" registry key opened by CRegistry::OpenEnvironment().  First, the existing string is retrieved from the value with CRegistry::GetEnvironment().  Then, the retrieved string is updated by checking to see if Value already exists in the string; if not, it is added to the end of the string delimited with a semicolon (;).  Finally, CRegistry::SetEnvironment() is used to replace the string in the associated value in the "Environment" registry key.  If the "Environment" registry key cannot be accessed, the function returns FALSE, and a MessageBox error is displayed.
BOOL CRegistry::RemoveEnvironment(CString Key, CString Value)
This member function updates the value associated with the specified Key in the "Environment" registry key opened by CRegistry::OpenEnvironment().  First, the existing string is retrieved from the associated value with CRegistry::GetEnvironment().  Then, the retrieved string is updated by checking to see if Value already exists in the string; if so, it is removed from the string.  Finally, CRegistry::SetEnvironment() is used to replace the string in the associated value in the "Environment" registry key.  If the "Environment" registry key cannot be accessed, the function returns FALSE, and a MessageBox error is displayed.
BOOL CRegistry::CloseEnvironment()
This member function closes the "Environment" registry key opened by CRegistry::OpenEnvironment().


[ CBinaryFile | TCommandLineInfo | CCommaFile | TDateCtrl | CDDE | CDdeClient | CDdeServer ]
[ CDirectoryLocator | CDirectoryDialog | CDirectoryFind | CDirectoryNew | CFileCopy | TFrameWnd ]
[ InterfaceExcel | CMaintFn | CPrintFile | CProcDialog | TPrintDialog | CProcPropertyPage ]
[ CProgress | CSDisCreate | CSDisFile | CSDisPage | CSDisView | CTableFile ]
[ CTaskIcon | TPresent | TTime | TDate | TDateTime | CTransferData | TWinApp | CXlTable ]

[ Stand-alone Programs | Standard Library | Conversion Functions | Utility Functions | COBOL Functions ]
[ Windows NT Library | COBOL Library | COBOL Interface | Command Prompt Abbreviations | Purchase Instructions ]

[ Home | Areas of Expertise | "We Do Windows" | Clients and Projects | Software Samples | Package Software Available ]
[ Contact Information | Business Software Philosophy | Church Software Philosophy ]
All contents of this web site are Copyright © Titus Information Systems, Inc., Phoenix, Arizona, U.S.A.