search

Home  >  Q&A  >  body text

c++ - dll 中返回 void * 类型的函数,如何在C#中声明?

C++中原型是怎样的:

extern "C" _declspec(dllexport) void * creat(const char* password);

整个怎么在C# 中调用啊,void * 正常对应的是 IntPtr,可总是说签名不正确,byte[]也不行

PHP中文网PHP中文网2828 days ago761

reply all(2)I'll reply

  • 黄舟

    黄舟2017-04-17 11:10:42

    You should post the question code first. I think it may be that CallingConvention is not specified:

    [DllImport("???.dll", EntryPoint = "creat", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
    [return: MarshalAs(UnmanagedType.SysInt)]
    public static extern IntPtr Create(...);
    

    reply
    0
  • 怪我咯

    怪我咯2017-04-17 11:10:42

    Incorrect signature? Are you sure it's not because your dll is 32-bit and your system is 64-bit?

    reply
    0
  • Cancelreply