Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Support Forum
Download Visual Studio Add-In

Terms of Use
Privacy Policy
regqueryvalue (advapi32)
 
.
Summary
TODO - a short description

C# Signature:

Flavor 1: (For strings)

/// <summary>
/// Retrieves the data associated with the default or unnamed value of a specified registry key. The data must be a null-terminated string.
/// </summary>
/// <param name="hKey">[in] A handle to an open registry key. The key must have been opened with the KEY_QUERY_VALUE access right.</param>
/// <param name="lpSubKey">[in] The name of the subkey of the hKey parameter for which the default value is retrieved. Key names are not case sensitive. If this parameter is NULL or points to an empty string, the function retrieves the default value for the key identified by hKey.</param>
/// <param name="lpValue">[out] A pointer to a buffer that receives 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 enables an application to determine the best way to allocate a buffer for the value's data.</param>
/// <param name="lpcbValue">[in, out] A pointer to a variable that specifies the size of the buffer pointed to by the lpValue parameter, in bytes. When the function returns, this variable contains the size of the data copied to lpValue, including any terminating null characters. If the data has the REG_SZ, REG_MULTI_SZ or REG_EXPAND_SZ type, this size includes any terminating null character or characters. For more information, see Remarks. If the buffer specified lpValue is not large enough to hold the data, the function returns ERROR_MORE_DATA and stores the required buffer size in the variable pointed to by lpcbValue. In this case, the contents of the lpValue buffer are undefined.</param>
/// <returns></returns>
[DllImport("advapi32.dll", SetLastError=true)]
internal static extern UInt32 RegQueryValue(
    IntPtr hKey,
    [MarshalAs(UnmanagedType.LPStr)]string lpSubKey,
    StringBuilder lpValue,
    ref UInt32 lpcbValue);

Flavor 2: (For binary)

/// <summary>
/// Retrieves the data associated with the default or unnamed value of a specified registry key. The data must be a null-terminated string.
/// </summary>
/// <param name="hKey">[in] A handle to an open registry key. The key must have been opened with the KEY_QUERY_VALUE access right.</param>
/// <param name="lpSubKey">[in] The name of the subkey of the hKey parameter for which the default value is retrieved. Key names are not case sensitive. If this parameter is NULL or points to an empty string, the function retrieves the default value for the key identified by hKey.</param>
/// <param name="lpValue">[out] A pointer to a buffer that receives 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 enables an application to determine the best way to allocate a buffer for the value's data.</param>
/// <param name="lpcbValue">[in, out] A pointer to a variable that specifies the size of the buffer pointed to by the lpValue parameter, in bytes. When the function returns, this variable contains the size of the data copied to lpValue, including any terminating null characters. If the data has the REG_SZ, REG_MULTI_SZ or REG_EXPAND_SZ type, this size includes any terminating null character or characters. For more information, see Remarks. If the buffer specified lpValue is not large enough to hold the data, the function returns ERROR_MORE_DATA and stores the required buffer size in the variable pointed to by lpcbValue. In this case, the contents of the lpValue buffer are undefined.</param>
/// <returns></returns>
[DllImport("advapi32.dll", SetLastError=true)]
internal static extern UInt32 RegQueryValue(
    IntPtr hKey,
    [MarshalAs(UnmanagedType.LPStr)]string lpSubKey,
    byte[] lpValue,
    ref UInt32 lpcbValue);

VB Signature:

<DllImport("advapi32.dll", EntryPoint:="RegQueryValueW", _
    SetLastError:=True, CharSet:=CharSet.Unicode, _
    ExactSpelling:=True, PreserveSig:=True, _
    CallingConvention:=CallingConvention.Winapi)> _
Private Shared Function RegQueryValue( _
   ByVal KeyClass As Integer, _
   ByVal SubKey As Integer, _
   ByVal ClassDescription As StringBuilder, _
   ByRef sizeB As Integer) As Integer
End Function

User-Defined Types:

None.

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

Please add some!

Documentation

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions