//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们。 写得有点乱请多包涵
  

解决方案 »

  1.   

    string strName = "D:\\111.mpg";
    定义个 stringbuild m=strName;
    然将 M 传入转化后的函数看看。C# 中试没有指针的。
      

  2.   

    谢谢楼上的朋友~gac520你好,stringbuilder我也曾想过,可是API SendDriverMessage函数的原型最后一个参数是整型,stringbuilder 应该传不了~zanfeng你好,函数已经全部贴出来了~
      

  3.   

    c#里面句柄是intptr
    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);
      

  4.   


    已 using HANDLE = System.IntPtr;
      

  5.   

    string strName = "D:\\111.mpg";
    定义个 stringbuild m=strName;
    然将 M 传入转化后的函数看看。C# 中试没有指针的。
      

  6.   

    回复楼上,试过了,传入后没有反应~C#是可以通过 unsafe 操作指针的,不过感觉取得好像不对~unsafe
    {
                  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();
                }
    }您可以测试一下,编译时在项目属性的生成中勾选允许不安全代码