using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace PatternSequencer
{
class Version
{
public string majorVersion;
public string minorVersion;
ushort* pmajorVersion;
ushort* pminorVersion;
ulong status;
[DllImport(@"c:\DOcuments\Myapp.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SRX_DllVersion")]
public static extern ulong SRX_DllVersion(ushort* pmajorVersion, ushort* pminorVersion);
public Version()
{
status = SRX_DllVersion(&pmajorVersion, &pminorVersion);
if (status)
{
majorVersion = "1 - " + *pmajorVersion;
minorVersion = "1 - " + *pminorVersion;
}
else
{
majorVersion = "0 - " + *pmajorVersion;
minorVersion = "0 - " + *pminorVersion;
}
}
}
}
它会抛出一个错误指针,并且固定大小的缓冲区只能在不安全的上下文中使用。如何将指针传递给 C++ dll?我是 C# 新手,请帮助我