C++ dll 可用C#调用
//获取系统中音视频设备名,和FFmpeg名字完全匹配
//dev 设备名数组
//type:0音频设备,1视频设备
//num,获取的设备数量
extern "C" TESTDLL_API HRESULT GetAVDevices(TCHAR * *dev, int type, int& num);
C#调用方式:
[DllImport("EnumAVDevice.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int GetAVDevices(IntPtr[] dev, int type, ref int num);
int num = 0;
var dev = new IntPtr[10];
for (int i = 0; i < 10; i++)
dev[i] = Marshal.AllocHGlobal(128);
GetAVDevices(dev, 0, ref num);
for (int i = 0; i >{Marshal.PtrToStringAuto(dev[i])}");
for (int i = 0; i < 10; i++)
Marshal.FreeHGlobal(dev[i]);
2021-06-25 18:05:11
26KB
ffmpeg
1