RegQueryValueEx (advapi32)
Last changed: philip.borchert@gmail.com-12.71.121.130

.
Summary
Retrieves the type and data for a specified value name associated with an open registry key.

C# Signature:

[DllImport("advapi32.dll", SetLastError=true)]
static extern int RegQueryValueEx(
    IntPtr hKey,
    string lpValueName,
    int lpReserved,
    out uint lpType,
    IntPtr lpData,
    ref uint lpcbData);

VB Signature:

Declare Function RegQueryValueEx Lib "advapi32.dll" (ByRef hKey As Integer, _
    lpValueName As String, _
    lpReserved As Integer, _
    lpType As Integer, _
    ByRef lpData As Integer, _
    lpcbData As Integer) As Integer

Key Types:
Type Value
REG_NONE 0
REG_SZ 1
REG_EXPAND_SZ 2
REG_BINARY 3
REG_DWORD 4
REG_DWORD_LITTLE_ENDIAN 4
REG_DWORD_BIG_ENDIAN 5
REG_LINK 6
REG_MULTI_SZ 7

User-Defined Types:

None.

Notes:

Managed APIs won't let you get raw REG_EXPAND_SZ values. You'll be forced to use Win32 APIs for this. Also, since .NET won'T give access to the key pointer, you'll have to browse the registry using pInvoke.

Tips & Tricks:

None.

Sample Code:

None.

Alternative Managed API:

namespace Microsoft.Win32;

classes Registery, RegistryKey

Documentation