C#操作神龙卡播放
//API声明
[DllImport("winmm.dll")]
public static extern int OpenDriver(string szDriverName, string szSectionName, int lParam2);
[DllImport("winmm.dll")]
public static extern int CloseDriver(HANDLE hDriver, int lParam1, int lParam2);
[DllImport("winmm.dll")]
public static extern int SendDriverMessage(HANDLE hDriver, int message, int lParam1, int lParam2);
//函数部分
public static uint FMPCommand(byte Command, byte hMPEGStream, ushort Flags, uint Value)
{
return (uint)SendDriverMessage(hReelDrv, DRV_USER + 1, (int)MAKELPARAM(MAKEWORD(Command, hMPEGStream), Flags), (int)Value);
}
private static uint MAKELPARAM(ushort wLow, ushort wHigh)
{
return (uint)(wHigh * 0x10000 + wLow);
// return (HiWord << 16) | (LoWord & 0xffff);
}
private static ushort MAKEWORD(byte bLow, byte bHigh)
{
return (ushort)(bLow | (bHigh << 8));
}
public static uint FMPOpen(ushort Flags, uint Filename)
{
return = FMPCommand(FMP_OPEN, 0, Flags, Filename);
}
public static uint FMPPlay(byte hStream, ushort Flags, uint Position)
{
return = FMPCommand(FMP_PLAY, hStream, Flags, Position);
}
用opendriver能正常打开神龙卡驱动,电视机上有反应,但是后面的打开文件,播放文件死活没有反应,
函数是从C++转过来的,C++中的MakeLparam,及makeword 是两个宏,转成C#了,然后就是FMPOPEN函数,
C++中语句为: FMPOpen( FMPF_FILE, (DWORD)strName );
strName 为字符串,文件路径,非常不理解转成(DWORD)strName,在C#中如何做?
如果是strName字符串的指针:
string strName = "D:\\111.mpg";
unsafe
{
fixed (char* p = fileName)
FMPAPI.FMPOpen(1, (uint)p);
}
如此处理不知道对不对,测试下来也没效果,请教搞过的GGJJ们。 写得有点乱请多包涵