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