//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们。 写得有点乱请多包涵
[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们。 写得有点乱请多包涵
定义个 stringbuild m=strName;
然将 M 传入转化后的函数看看。C# 中试没有指针的。
DllImport("winmm.dll")]
public static extern int CloseDriver(intptr hDriver, int lParam1, int lParam2); [DllImport("winmm.dll")]
public static extern int SendDriverMessage(intptr hDriver, int message, int lParam1, int lParam2);
已 using HANDLE = System.IntPtr;
定义个 stringbuild m=strName;
然将 M 传入转化后的函数看看。C# 中试没有指针的。
{
string theChar = "D:\\adf.mpg";
fixed (char* pChar = theChar)
{
void* pVoid = pChar;
int* pInt = (int*)pVoid; System.Console.WriteLine("Value of theChar = {0}", theChar);
System.Console.WriteLine("Address of theChar = {0:X2}", (int)pChar);
System.Console.WriteLine("Value of pChar = {0}", *pChar);
System.Console.WriteLine("Value of pInt = {0}", *pInt);
Console.Read();
}
}您可以测试一下,编译时在项目属性的生成中勾选允许不安全代码