【发布时间】:2015-10-12 18:24:48
【问题描述】:
这是 C# 代码。
namespace CameraTest
{
class Program
{
static void Main(string[] args)
{
string[] lst = new string[10];
for (int i = 0; i < 10; i++)
{
lst[i] = new string(' ', 33);
}
bool sync = true;
bool ret = CameraCalls.CAM_EnumCameraEx(sync, lst, 10, 33);
}
}
public static class CameraCalls
{
[DllImport("CamDriver64.dll")]
public static extern bool CAM_EnumCameraEx(bool sync,
[MarshalAs(UnmanagedType.LPArray)]
string[] lst,
long maxCam,
long maxChar);
}
}
非托管方法是这样的。
BOOL WINAPI CAM_EnumCameraEx(BOOL bSynchronized, char **ppCameraList, long lMaxCamera, long lMaxCharacter);
该方法写入传入的字符串数组。有没有办法从 c# 调用这个方法并使非托管代码能够写入字符串数组?
【问题讨论】:
-
那个文档有答案,我所要做的就是使用 In, Out