DWORD OREnumKey(
__in ORHKEY Handle,
__in DWORD dwIndex,
__out PWSTR lpName,
__inout PDWORD lpcName,
__out_opt PWSTR lpClass,
__inout_opt PDWORD lpcClass,
__out_opt PFILETIME lpftLastWriteTime
);
我的代码
[DllImport("offreg.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern uint OREnumKey(IntPtr Handle, IntPtr dwIndex, [MarshalAs(UnmanagedType.LPWStr)]out StringBuilder lpName, ref IntPtr lpcName, [MarshalAs(UnmanagedType.LPWStr)]out StringBuilder lpClass, ref IntPtr lpcClass, out System.Runtime.InteropServices.ComTypes.FILETIME lpftLastWriteTime);
IntPtr myKey = hiveid;
IntPtr dwindex=(IntPtr)0;
StringBuilder lpName=new StringBuilder("",255);
IntPtr lpcName = (IntPtr)0;
StringBuilder lpClass=new StringBuilder("",255);
IntPtr lpcClass = (IntPtr)11;
System.Runtime.InteropServices.ComTypes.FILETIME lpftLastWriteTime;
uint ret3 = OREnumKey(myKey, dwindex, out lpName, ref lpcName, out lpClass, ref lpcClass, out lpftLastWriteTime);
ret3=ERROR_MORE_DATA 234 问题可能是错误的 StringBuilder 大小或 FILETIME 2nd 我应该如何从 C# 调用 PWSTR 参数?
[MarshalAs(UnmanagedType.LPWStr)]out StringBuilder lpName
这是正确的吗?