This code has been viewed 109298 times.
Instructions: Copy the declarations and code below and paste directly into your VB project.
Declarations:
Code:'PURPOSE: To create a registry key 'PARAMETERS: 'KeyName: Name of key to create 'ParentKey: Top level key under which the new key will be created 'For example: HKEY_CURRENT_USER 'Use one of the constants defined in delcarations 'RETURNS: True if executes without error, false otherwise 'can also be used to create nested subkeys 'e.g. CreateKey(HKEY_LOCAL_MACHINE/Software/MyApp/Settings) Public Function CreateKey(KeyName As String, _ ParentKey As Long) As Boolean Dim lNewKeyHnd As Long Dim lAns As Long lAns = RegCreateKeyEx(ParentKey, KeyName, 0&, vbNullString, _ REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0&, lNewKeyHnd, lAns) RegCloseKey lNewKeyHnd CreateKey = (lAns = 0) 'Altenatively, return specific error inormation 'See declarations for error codes End Function
No Text Boxes