DWORD OREnumValue(
__in ORHKEY Handle,
__in DWORD dwIndex,
__out PWSTR lpValueName,
__inout PDWORD lpcValueName,
__out_opt PDWORD lpType,
__out_opt PBYTE lpData,
__inout_opt PDWORD lpcbData
);
My Code:
public static extern uint OREnumValue(IntPtr Handle, uint dwIndex, [MarshalAsAttribute(UnmanagedType.LPWStr)] out StringBuilder lpValueName, ref int lpcValueName, out uint lpType, out IntPtr lpData, ref int lpcbData);
IntPtr Handle=mykey;
uint dwIndex=0;
StringBuilder lpValueName = new StringBuilder(16383);
int lpcValueName=lpValueName.Capacity;
uint lpType=0;
IntPtr lpData;
int lpcbData = int.MaxValue;
uint ret3= OREnumValue(Handle, dwIndex, out lpValueName, ref lpcValueName, out lpType, out lpData, ref lpcbData);
This gives an error:
ret3=ERROR_MORE_DATA 259
I think problem is either in
- lpData - what should I use for PBYTE? Or
- lpcbData - what capacity should I use?
From MSDN
If the buffer specified by lpData 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 lpcbData. In this case, the contents of lpData are undefined.