1
如何从下面的DLL中获取值? offreg.dll。ERROR_MORE_DATA --- PVOID和C#---非托管类型
在我下面的代码,我已经成功地打开蜂箱,关键现在我想拿到钥匙的价值,我一直运行到ERROR_MORE_DATA(234)错误。
这里是C++的.dll:
DWORD
ORAPI
ORGetValue (
__in ORHKEY Handle,
__in_opt PCWSTR lpSubKey,
__in_opt PCWSTR lpValue,
__out_opt PDWORD pdwType,
__out_bcount_opt(*pcbData) PVOID pvData,
__inout_opt PDWORD pcbData
);
这里是我的C#代码:
[DllImport("offreg.dll", CharSet = CharSet.Auto, EntryPoint = "ORGetValue", SetLastError = true, CallingConvention = CallingConvention.StdCall)]
public static extern uint ORGetValue(IntPtr Handle, string lpSubKey, string lpValue, out uint pdwType, out StringBuilder pvData, out uint pcbData);
IntPtr myHive;
IntPtr myKey;
StringBuilder myValue = new StringBuilder("", 256);
uint pdwtype;
uint pcbdata;
uint ret3 = ORGetValue(myKey, "", "DefaultUserName", out pdwtype, out myValue, out pcbdata);
所以这个问题似乎是围绕PVOID pvData我不能似乎得到正确的类型,或正确的缓冲区大小。始终与234错误。
注:当运行这个命令pcbdata = 28 ......所以256应该是绰绰有余。
任何帮助将不胜感激。
如上图所示,我已经试过字符串生成器... ...串的IntPtr ...等,这些都不是能够处理出PVData的...
谢谢。
这是在头版上有10个月大的问题,因为有人决定对其进行编辑14几分钟前。 – shf301 2011-02-06 21:15:10