Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than advapi32, prefix the name with the module name and a period.
RegQueryInfoKey (advapi32)
.
C# Signature:
[DllImport("advapi32.dll", EntryPoint="RegQueryInfoKey", CallingConvention=CallingConvention.Winapi, SetLastError=true)]
extern private static int RegQueryInfoKey(
UIntPtr hkey,
out StringBuilder lpClass,
ref uint lpcbClass,
IntPtr lpReserved,
out uint lpcSubKeys,
out uint lpcbMaxSubKeyLen,
out uint lpcbMaxClassLen,
out uint lpcValues,
out uint lpcbMaxValueNameLen,
out uint lpcbMaxValueLen,
out uint lpcbSecurityDescriptor,
IntPtr lpftLastWriteTime);
VB Signature:
Public Declare Auto Function RegQueryInfoKey Lib "advapi32.dll" (
ByVal hKey As UIntPtr,
ByRef lpClass As System.Text.StringBuilder,
ByRef lpcbClass As Integer,
ByVal lpReserved As IntPtr,
ByRef lpcSubKeys As Integer,
ByRef lpcbMaxSubKeyLen As Integer,
ByRef lpcbMaxClassLen As Integer,
ByRef lpcValues As Integer,
ByRef lpcbMaxValueNameLen As Integer,
ByRef lpcMaxValueLen As Integer,
ByRef lpcbSecurityDescriptor As Integer,
ByVal lpftLastWriteTime As IntPtr
) As Integer
User-Defined Types:
None.
Alternative Managed API:
Do you know one? Please contribute it!
Notes:
Beware both lpcbMaxSubKeyLen and lpcbMaxValueNameLen return the length of the longest SubKey/Value Name, in Unicode characters. However, the size does not include the terminating null character!
Tips & Tricks:
Please add some!
Sample Code:
Dim hk As UIntPtr : hk = RegOpenKeyEx ...
Dim lpcSubKeys As Integer
Dim lpcbMaxSubKeyLen As Integer
Dim lpcbMaxClassLen As Integer
Dim lpcValues As Integer
Dim lpcbMaxValueNameLen As Integer
Dim lpcMaxValueLen As Integer
Dim lpcbSecurityDescriptor As Integer
Dim sbClass = New Text.StringBuilder(1024)
Dim sbClassLen = sbClass.Capacity
r = PInvoke.RegQueryInfoKey(hk, sbClass, sbClassLen, IntPtr.Zero, lpcSubKeys, lpcbMaxSubKeyLen, lpcbMaxClassLen, lpcValues, lpcbMaxValueNameLen, lpcMaxValueLen, lpcbSecurityDescriptor, IntPtr.Zero)
Console.WriteLine("Return={0}, hkey={1}, lpcSubKeys={2}, lpcbMaxSubKeyLen={3}, lpcbMaxClassLen={4}, lpcValues={5}, lpcbMaxValueNameLen={6}, lpcMaxValueLen={7}, lpcbSecurityDescriptor={8}",
r,
hk,
lpcSubKeys,
lpcbMaxSubKeyLen,
lpcbMaxClassLen,
lpcValues,
lpcbMaxValueNameLen,
lpcMaxValueLen,
lpcbSecurityDescriptor)
Console.WriteLine("Class={0}", sbClass.ToString) 'usually empty
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).