[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);
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
None.
Do you know one? Please contribute it!
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!
Please add some!
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