Esempio n. 1
0
        public static bool DoesPipeStillExist(int requestedpipe)
        {
            try
            {
                String PipeToAdd;

                IntPtr ptr = FindFirstFile(@"\\.\pipe\*", out WIN32_FIND_DATA lpFindFileData);
                PipeToAdd = Path.GetFileName(lpFindFileData.cFileName);
                if (PipeToAdd.Contains(String.Format("OmniMIDIDbg{0}", requestedpipe)))
                {
                    return(true);
                }

                while (FindNextFile(ptr, out lpFindFileData))
                {
                    PipeToAdd = Path.GetFileName(lpFindFileData.cFileName);
                    if (PipeToAdd.Contains(String.Format("OmniMIDIDbg{0}", requestedpipe)))
                    {
                        return(true);
                    }
                }
                FindClose(ptr);

                return(false);
            }
            catch { return(false); }
        }
Esempio n. 2
0
        public static String[] GetDebugPipesList()
        {
            List <String> OMPipes = new List <string>();

            try
            {
                Int32           Found = 0;
                String          PipeToAdd;
                WIN32_FIND_DATA lpFindFileData;

                IntPtr ptr = FindFirstFile(@"\\.\pipe\*", out lpFindFileData);
                PipeToAdd = Path.GetFileName(lpFindFileData.cFileName);
                if (PipeToAdd.Contains("OmniMIDIDbg"))
                {
                    OMPipes.Add(String.Format("Debug pipe {0} (OmniMIDIDbg{0})", Regex.Match(PipeToAdd, @"\d+").Value));
                    Found++;
                }

                while (FindNextFile(ptr, out lpFindFileData))
                {
                    PipeToAdd = Path.GetFileName(lpFindFileData.cFileName);
                    if (PipeToAdd.Contains("OmniMIDIDbg"))
                    {
                        OMPipes.Add(String.Format("Debug pipe {0} (OmniMIDIDbg{0})", Regex.Match(PipeToAdd, @"\d+").Value));
                        Found++;
                    }
                }
                FindClose(ptr);

                return(OMPipes.ToArray());
            }
            catch (Exception ex)
            {
                // If something goes wrong, here's an error handler
                MessageBox.Show(ex.ToString() + "\n\nPress OK to stop the debug mode.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.ExitThread();

                return(new String[] { });
            }
        }