Results 1 to 4 of 4

Thread: The registry and combobox

  1. #1

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827

    The registry and combobox

    I have combobox which will add the item (whatever) you type in itself. Now I want to save all the items in the combobox in registry so that I can retrieve them later.

    How do I do that and how do I add them back to the combobox when my program starts?

    Thanks
    Baaaaaaaaah

  2. #2
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    There are several API functions that can help - look them up at MSDN.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  3. #3
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    RegSetValue
    The RegSetValue function sets the data for the default or unnamed value of a specified registry key. The data must be a text string.

    This function is provided for compatibility with Windows version 3.1. Win32-based applications should use the RegSetValueEx function, which allows you to set any number of named values of any data type.

    LONG RegSetValue(
    HKEY hKey, // handle to key to set value for
    LPCTSTR lpSubKey, // address of subkey name
    DWORD dwType, // type of value
    LPCTSTR lpData, // address of value data
    DWORD cbData // size of value data
    );

    Parameters
    hKey
    Handle to a currently open key or any of the following predefined reserved handle values:
    HKEY_CLASSES_ROOT
    HKEY_CURRENT_CONFIG
    HKEY_CURRENT_USER
    HKEY_LOCAL_MACHINE
    HKEY_USERS
    Windows NT: HKEY_PERFORMANCE_DATA
    Windows 95 and Windows 98: HKEY_DYN_DATA

    lpSubKey
    Pointer to a null-terminated string containing the name of a subkey of the hKey parameter. The function sets the default value of the specified subkey. If this parameter is NULL or points to an empty string, the function sets the default value of the key identified by hKey.
    dwType
    Specifies the type of information to be stored. This parameter must be the REG_SZ type. To store other data types, use the RegSetValueEx function.
    lpData
    Pointer to a null-terminated string containing the data to set for the default value of the specified key.
    cbData
    Specifies the length, in bytes, of the string pointed to by the lpData parameter, not including the terminating null character.
    Return Values
    If the function succeeds, the return value is ERROR_SUCCESS.

    If the function fails, the return value is a nonzero error code defined in WINERROR.H. You can use the FormatMessage function with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a generic description of the error.

    Remarks
    If the key specified by the lpSubKey parameter does not exist, the RegSetValue function creates it.

    Value lengths are limited by available memory. Long values (more than 2048 bytes) should be stored as files with the filenames stored in the registry. This helps the registry perform efficiently.

    The key identified by the hKey parameter must have been opened with KEY_SET_VALUE access. To open the key, use the RegCreateKeyEx or RegOpenKeyEx function. If the ANSI version of this function is used (either by explicitly calling RegSetValueA or by not defining UNICODE before including the WINDOWS.H file), the lpData parameter must be an ANSI character string. The string is converted to Unicode before it is stored in the registry.
    RegOpenKey
    The RegOpenKey function opens the specified key. This function is provided for compatibility with Windows version 3.1. Win32-based applications should use the RegOpenKeyEx function.

    LONG RegOpenKey(
    HKEY hKey, // handle to open key
    LPCTSTR lpSubKey, // address of name of subkey to open
    PHKEY phkResult // address of handle to open key
    );

    Parameters
    hKey
    Handle to a currently open key or any of the following predefined reserved handle values:
    HKEY_CLASSES_ROOT
    HKEY_CURRENT_CONFIG
    HKEY_CURRENT_USER
    HKEY_LOCAL_MACHINE
    HKEY_USERS
    Windows NT: HKEY_PERFORMANCE_DATA
    Windows 95 and Windows 98: HKEY_DYN_DATA

    The key opened by the RegOpenKey function is a subkey of the key identified by hKey.

    lpSubKey
    Pointer to a null-terminated string containing the name of the key to open. This key must be a subkey of the key identified by the hKey parameter. If this parameter is NULL or a pointer to an empty string, the function returns the same handle that was passed in.
    phkResult
    Pointer to a variable that receives a handle to the opened key. When you no longer need the returned handle, call the RegCloseKey function to close it.
    Return Values
    If the function succeeds, the return value is ERROR_SUCCESS.

    If the function fails, the return value is a nonzero error code defined in WINERROR.H. You can use the FormatMessage function with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a generic description of the error.

    Remarks
    The RegOpenKey function uses the default security access mask to open a key. If opening the key requires a different mask, the function fails, returning ERROR_ACCESS_DENIED. An application should use the RegOpenKeyEx function to specify an access mask in this situation.

    Unlike the RegCreateKey function, RegOpenKey does not create the specified key if the key does not exist in the database.
    RegQueryValue
    The RegQueryValue function retrieves the data associated with the default or unnamed value of a specified registry key. The data must be a null-terminated string.

    This function is provided for compatibility with Windows version 3.1. Win32-based applications should use the RegQueryValueEx function.

    LONG RegQueryValue(
    HKEY hKey, // handle to key to query
    LPCTSTR lpSubKey,
    // name of subkey to query
    LPTSTR lpValue, // buffer for returned string
    PLONG lpcbValue // receives size of returned string
    );

    Parameters
    hKey
    Handle to a currently open key or any of the following predefined reserved handle values:
    HKEY_CLASSES_ROOT
    HKEY_CURRENT_CONFIG
    HKEY_CURRENT_USER
    HKEY_LOCAL_MACHINE
    HKEY_USERS
    Windows NT: HKEY_PERFORMANCE_DATA
    Windows 95 and Windows 98: HKEY_DYN_DATA

    lpSubKey
    Pointer to a null-terminated string containing the name of the subkey of the hKey parameter for which the default value is retrieved. If this parameter is NULL or points to an empty string, the function retrieves the default value for the key identified by hKey.
    lpValue
    Pointer to a buffer that receives the null-terminated string associated with the default value of the specified key.
    If lpValue is NULL, and lpcbValue is non-NULL, the function returns ERROR_SUCCESS, and stores the size of the data, in bytes, in the variable pointed to by lpcbValue. This lets an application determine the best way to allocate a buffer for the value's data.

    lpcbValue
    Pointer to a variable that specifies the size, in bytes, of the buffer pointed to by the lpValue parameter. When the function returns, this variable contains the size of the data copied to lpValue, including the terminating null character.
    If the buffer specified by lpValue parameter is not large enough to hold the data, the function returns the value ERROR_MORE_DATA, and stores the required buffer size, in bytes, into the variable pointed to by lpcbValue.

    In all cases the value returned in lpcbValue includes the size of the terminating null character in the string.

    Return Values
    If the function succeeds, the return value is ERROR_SUCCESS.

    If the function fails, the return value is a nonzero error code defined in WINERROR.H. You can use the FormatMessage function with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a generic description of the error.

    Remarks
    The key identified by the hKey parameter must have been opened with KEY_QUERY_VALUE access (KEY_READ access includes KEY_QUERY_VALUE access).

    If the ANSI version of this function is used (either by explicitly calling RegQueryValueA or by not defining UNICODE before including the WINDOWS.H file), this function converts the stored Unicode string to an ANSI string before copying it to the buffer specified by the lpValue parameter.
    If you don't know how to use them i will send you some example later.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  4. #4

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    Yes please send me some examples but I can add/edit/delete a single key like "Version#".
    The combobox has lots of items in it so I don't if I make that many keys or I make one key that saperates the items by a specific symbol like "$$"
    Can you give me an example of that please?
    Baaaaaaaaah

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width