我在 C++ 中有这行代码
WD_OpenDevice(PCSTR szDevPath, HANDLE *phDevice, HANDLE ahChannels[], int *pnChannelNum, int iVideoStandard = WD_VID_STD_PAL, PCSTR szUser = NULL, PCSTR szPswd = NULL);
然后调用它
WD_OpenDevice("xxxxxxxx", &m_hDev, m_ahChannels, &m_nChannelNum);
C# 中 int * 和 HANDLE * 的等价物是什么?
我已使用 DllImport 在 C# 中将其转换为此代码。但这行不通。
[DllImport("WD_SDK.dll", SetLastError = true)]
static extern int WD_OpenDevice(string szDevPath, IntPtr phDevice, IntPtr[] ahChannels, int pnChannelNum, int iVideoStandard = 1, string szUser = null, string szPswd = null);
我叫它
IntPtr[] m_ahChannels = new IntPtr[4];
int m_nChannelNum = 0;
IntPtr m_hDev = new IntPtr();
a = WD_OpenDevice("wdvr://localhost/qqdvr", m_hDev, m_ahChannels, m_nChannelNum);
引发的错误:
最佳答案
WD_OpenDevice(PCSTR szDevPath,
HANDLE *phDevice,
HANDLE ahChannels[],
int *pnChannelNum,
int iVideoStandard = WD_VID_STD_PAL,
PCSTR szUser = NULL,
PCSTR szPswd = NULL);
是
[DllImport("WD_SDK.dll", SetLastError = true, CharSet = CharSet.Ansi)]
static extern int WD_OpenDevice(string szDevPath,
ref IntPtr phDevice,
IntPtr[] ahChannels,
ref int pnChannelNum,
int iVideoStandard = 1,
string szUser = null,
string szPswd = null);
根据函数的作用,您可能希望将 ref
替换为 out
。
关于c# - int * 和 HANDLE * 在 C# 中等效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22653064/