Beispiel #1
0
        private bool IsAlreadyRunning()
        {
            AppSettings setting = new AppSettings();

            if (setting.IsAllowRunningMultiApps ||
                Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Count() <= 1)
            {
                return(false);
            }

            return(ProcessInterop.SendFilePathToApp(m_FeatureFilePath));
        }
Beispiel #2
0
        public void EnsureThat_ProcessInterop_ResolveProgramFullPath_ReturnsCorrect(string program, bool expected)
        {
            var result = ProcessInterop.ResolveProgramFullPath(program);

            if (expected)
            {
                Assert.IsNotNull(result);
            }
            else
            {
                Assert.IsNull(result);
            }
        }
        // Vista +
        public static string GetExecutablePath(int dwProcessId)
        {
            StringBuilder buffer   = new StringBuilder(1024);
            IntPtr        hprocess = ProcessInterop.OpenProcess(ProcessInterop.PROCESS_QUERY_LIMITED_INFORMATION, false, dwProcessId);

            if (hprocess == IntPtr.Zero)
            {
                return(string.Empty);
            }
            try
            {
                int size = buffer.Capacity;
                if (ProcessInterop.QueryFullProcessImageName(hprocess, 0, buffer, out size))
                {
                    return(buffer.ToString());
                }
            }
            finally
            {
                ProcessInterop.CloseHandle(hprocess);
            }
            return(string.Empty);
        }
Beispiel #4
0
 private void CreateSeparateProcessButton_Click(object sender, RoutedEventArgs args)
 {
     ProcessInterop.CreateProcess(System.Environment.GetEnvironmentVariable("ComSpec"), "/C start notepad.exe text_separate.txt", true, true);
 }
Beispiel #5
0
 public OpenUriCommand()
     : base(path => ProcessInterop.CreateProcess(null, $"cmd.exe /C start {path.AbsoluteUri}", true, true))
 {
 }
Beispiel #6
0
 public MouseManager()
 {
     using (var process = Process.GetCurrentProcess())
         using (var module = process.MainModule)
         {
             HookCallback = HookProc;
             HookHandle   = WI.SetWindowsHookEx(WI.HookType.WH_MOUSE_LL, HookCallback, ProcessInterop.GetModuleHandle(module.ModuleName), 0);
         }
 }