Esempio n. 1
0
        public static AcmDriver AddLocalDriver(string driverFile)
        {
            IntPtr intPtr = NativeMethods.LoadLibrary(driverFile);

            if (intPtr == IntPtr.Zero)
            {
                throw new ArgumentException("Failed to load driver file");
            }
            IntPtr procAddress = NativeMethods.GetProcAddress(intPtr, "DriverProc");

            if (procAddress == IntPtr.Zero)
            {
                NativeMethods.FreeLibrary(intPtr);
                throw new ArgumentException("Failed to discover DriverProc");
            }
            IntPtr   hAcmDriver;
            MmResult mmResult = AcmInterop.acmDriverAdd(out hAcmDriver, intPtr, procAddress, 0, AcmDriverAddFlags.Function);

            if (mmResult != MmResult.NoError)
            {
                NativeMethods.FreeLibrary(intPtr);
                throw new MmException(mmResult, "acmDriverAdd");
            }
            AcmDriver acmDriver = new AcmDriver(hAcmDriver);

            if (string.IsNullOrEmpty(acmDriver.details.longName))
            {
                acmDriver.details.longName = "Local driver: " + Path.GetFileName(driverFile);
                acmDriver.localDllHandle   = intPtr;
            }
            return(acmDriver);
        }
Esempio n. 2
0
 public static AcmDriver FindByShortName(string shortName)
 {
     foreach (AcmDriver current in AcmDriver.EnumerateAcmDrivers())
     {
         if (current.ShortName == shortName)
         {
             return(current);
         }
     }
     return(null);
 }
Esempio n. 3
0
        public static void RemoveLocalDriver(AcmDriver localDriver)
        {
            if (localDriver.localDllHandle == IntPtr.Zero)
            {
                throw new ArgumentException("Please pass in the AcmDriver returned by the AddLocalDriver method");
            }
            MmResult arg_3A_0 = AcmInterop.acmDriverRemove(localDriver.driverId, 0);

            NativeMethods.FreeLibrary(localDriver.localDllHandle);
            MmException.Try(arg_3A_0, "acmDriverRemove");
        }
Esempio n. 4
0
 public static bool IsCodecInstalled(string shortName)
 {
     using (IEnumerator <AcmDriver> enumerator = AcmDriver.EnumerateAcmDrivers().GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             if (enumerator.Current.ShortName == shortName)
             {
                 return(true);
             }
         }
     }
     return(false);
 }