我有我想从一个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