我有我想從一個DLL導入的方法和它的簽名:我已經試過的DllImport與char *
[DllImport("mydll.dll")]
public static extern bool GetDriveLetter(byte[] DriveLetter);
和
[DllImport("mydll.dll")]
public static extern bool GetDriveLetter(StringBuilder DriveLetter);
BOOL GetDriveLetter(OUT char* DriveLetter)
但在DriveLetter變量中都沒有返回任何內容。
UnmanagedType.I1是什麼意思? – Malfist 2010-04-02 19:58:04
@Malfist,值I1告訴CLR將該值編組爲1字節整數。在這個例子中它實際上是不正確的,因爲I4是正確的值(稍後更新)。至於爲什麼看看我編寫的關於編組布爾值的博客條目:http://blogs.msdn.com/jaredpar/archive/2008/10/14/pinvoke-and-bool-or-should-i-say-bool .aspx – JaredPar 2010-04-02 20:00:05
當我把它做成I4時,我得到MarshalDirectiveException – Malfist 2010-04-02 20:34:48