1
這是我的C++結構(使用多字節字符集)元帥管理的String []非託管的char **
typedef struct hookCONFIG {
int threadId;
HWND destination;
const char** gameApps;
const char** profilePaths;
} HOOKCONFIG;
和.NET結構
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct HOOKCONFIG {
public int threadId;
public IntPtr destination;
// MarshalAs?
public string[] gameApps;
// MarshalAs?
public string[] profilePaths;
}
我得到了一些問題,即如何我是否編組字符串數組? 當我訪問結構變量「profilePaths」在C++我得到這樣的錯誤:
類型「System.AccessViolationException」的未處理的異常發生在APP.EXE
其他信息:嘗試讀取或寫保護的內存。這通常是指示其他內存已損壞的 。
MessageBox(0, cfg.profilePaths[0], "Title", MB_OK); // error ... Orz
你可以試試嗎評論HWND/IntPtr? – 2010-04-20 02:08:57