c++ - dll 中返回 void * 类型的函数,如何在C#中声明?
PHP中文网
PHP中文网 2017-04-17 11:08:42
0
2
703

C++中原型是怎样的:

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

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

PHP中文网
PHP中文网

认证0级讲师

répondre à tous(2)
黄舟

你应该先贴问题代码。 我觉得可能是没有指定CallingConvention

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

签名不正确?你确定不是因为你的dll是32位而你的系统是64位导致的?

Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!