Beispiel #1
0
 public void ThreadRunner()
 {
     var dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
     API.SECURITY_ATTRIBUTES processAttr = new API.SECURITY_ATTRIBUTES();
     API.SECURITY_ATTRIBUTES threadAttr = new API.SECURITY_ATTRIBUTES();
     API.STARTUPINFO si = new API.STARTUPINFO();
     API.PROCESS_INFORMATION pi = new API.PROCESS_INFORMATION();
     processAttr.nLength = Marshal.SizeOf(processAttr);
     threadAttr.nLength = Marshal.SizeOf(threadAttr);
     
     // NORMAL_PRIORITY_CLASS: 0x0020
     var bSuccess = API.CreateProcess(Environment.GetEnvironmentVariable("ComSpec"), "/c \"" + dir + "\\boot.cmd\"",
         ref processAttr, ref threadAttr, false, 0x0020, IntPtr.Zero, dir, ref si, out pi);
     
     this.pi = pi;
     eventLog1.WriteEntry(String.Format("Process id: {0}", pi.dwProcessId));
     if (!bSuccess)
     {
         this.Stop();
     }
 }
Beispiel #2
0
        public void ThreadRunner()
        {
            var dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            API.SECURITY_ATTRIBUTES processAttr = new API.SECURITY_ATTRIBUTES();
            API.SECURITY_ATTRIBUTES threadAttr  = new API.SECURITY_ATTRIBUTES();
            API.STARTUPINFO         si          = new API.STARTUPINFO();
            API.PROCESS_INFORMATION pi          = new API.PROCESS_INFORMATION();
            processAttr.nLength = Marshal.SizeOf(processAttr);
            threadAttr.nLength  = Marshal.SizeOf(threadAttr);

            // NORMAL_PRIORITY_CLASS: 0x0020
            var bSuccess = API.CreateProcess(Environment.GetEnvironmentVariable("ComSpec"), "/c \"" + dir + "\\boot.cmd\"",
                                             ref processAttr, ref threadAttr, false, 0x0020, IntPtr.Zero, dir, ref si, out pi);

            this.pi = pi;
            eventLog1.WriteEntry(String.Format("Process id: {0}", pi.dwProcessId));
            if (!bSuccess)
            {
                this.Stop();
            }
        }