Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/304.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用ulong*参数从c#中的dll导入函数_C#_Windows_Dll_Pinvoke_Dllimport - Fatal编程技术网

使用ulong*参数从c#中的dll导入函数

使用ulong*参数从c#中的dll导入函数,c#,windows,dll,pinvoke,dllimport,C#,Windows,Dll,Pinvoke,Dllimport,我在visual studio 2015中使用windows 7和c#进行开发; 在我的其他c程序中导入dll中使用的函数时出现问题: unsigned long ulaVersion[2]; MHM_GetDLLVersion(ulaVersion); cout << "MHM_1SL_interface.dll Version: " << ulaVersion[1] << "." << ulaVersion[0] << endl &

我在visual studio 2015中使用windows 7和c#进行开发; 在我的其他c程序中导入dll中使用的函数时出现问题:

unsigned long ulaVersion[2];
MHM_GetDLLVersion(ulaVersion);
cout << "MHM_1SL_interface.dll Version: " << ulaVersion[1] << "." << ulaVersion[0] << endl << endl;
该函数可以工作并打印1.8

现在我试着用c#

我试图使用这个,但我收到了“8”的结果。。。 我错在哪里?
哪种方法可以将ulong*参数传递给c#?

中的函数?它是一个数组,因此参数必须是UInt32[],无ref。请确保传递一个已经足够大且包含2个元素的参数。长的64位不是吗?如果是这样的话,那么您可能需要将UInt32换成UInt64@brandonstrong不是在Windows上的C++。这里的
long
是32位。@Hans Passant当然可以。..ThanksIt是一个数组,所以参数必须是UInt32[],没有ref。一定要传递一个已经足够大且包含2个元素的参数。长的64位不是吗?如果是这样的话,那么您可能需要将UInt32换成UInt64@brandonstrong不是在Windows上的C++。这里的
long
是32位。@Hans Passant当然可以了。谢谢
unsigned long __stdcall MHM_GetDLLVersion(unsigned long *pulDllVersion);
[DllImport(@"MHM_1SL_interface.dll", CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 MHM_GetDLLVersion(ref UInt32 ulaVersion);