Esempio n. 1
0
        public static bool MMLoad(ref MM_LOAD load, string baseDirectory)
        {
            string mmLibPath = GetMultiMediaPath(baseDirectory);

            if (!string.IsNullOrEmpty(mmLibPath))
            {
                try
                {
                    if (!MMInterop.SetDllDirectory(mmLibPath))
                    {
                        Exception e = new System.ComponentModel.Win32Exception();
                        throw new DllNotFoundException("Error, Unable to load library: " + mmLibPath, e);
                    }
                    else
                    {
                        load.Size = (uint)Marshal.SizeOf(typeof(MM_LOAD));
                        mmStatus sts = mmMethods.mmLoad(ref load);
                        if (sts == mmStatus.MM_STS_NONE)
                        {
                            return(true);
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                }
            }
            Console.WriteLine($"Error, failed to Load mmAPI from {baseDirectory}");
            return(false);
        }
Esempio n. 2
0
        public static bool MMLoad(ref MM_LOAD load, string baseDirectory)
        {
            string mmLibPath = GetMultiMediaPath(baseDirectory);

            if (!string.IsNullOrEmpty(mmLibPath))
            {
                try
                {
                    if (!MMInterop.SetDllDirectory(mmLibPath))
                    {
                        Exception e = new System.ComponentModel.Win32Exception();
                        throw new DllNotFoundException("Error, Unable to load library: " + mmLibPath, e);
                    }
                    else
                    {
                        load.Size = (uint)Marshal.SizeOf(typeof(MM_LOAD));
                        mmStatus sts = mmMethods.mmLoad(ref load);
                        if (sts == mmStatus.MM_STS_NONE)
                        {
                            bool activated = false;
                            if ((load.OutFlags & MM_LOAD_CONTEXT.MM_LOAD_CONTEXT_ACTIVATED) == MM_LOAD_CONTEXT.MM_LOAD_CONTEXT_ACTIVATED)
                            {
                                activated = true;
                            }

                            String loadString = String.Format("mmAPI v{0}.{1}.{2} activated={3} flags={4}",
                                                              load.Version.Major.ToString().PadLeft(2, '0'), load.Version.Minor.ToString().PadLeft(2, '0'), load.Version.Micro.ToString().PadLeft(2, '0'),
                                                              activated, load.OutFlags);

                            Console.WriteLine(loadString);
                            return(true);
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                }
            }
            Console.WriteLine($"Error, failed to Load mmAPI from {baseDirectory}");
            return(false);
        }
Esempio n. 3
0
 public static bool MMLoadEx(ref MM_LOAD load, string path)
 {
     try
     {
         if (MMInterop.SetDllDirectory(path))
         {
             load.Size = (uint)Marshal.SizeOf(typeof(MM_LOAD));
             mmStatus sts = mmMethods.mmLoad(ref load);
             if (sts == mmStatus.MM_STS_NONE)
             {
                 return(true);
             }
         }
     }
     catch (Exception e)
     {
         //Console.WriteLine(e.ToString());
     }
     return(false);
 }