createprocess

How to bring window on top of the process created through CreateProcess

依然范特西╮ 提交于 2019-12-01 03:34:16
问题 I am launching a process from my application using CreateProcess API and I want to bring the window of the new process to top. Is there a way to do it? Do we have any flag or something like that with CreateProcess? 回答1: You can try to use the STARTUPINFO structure which is passed in with CreateProcess and set SW_SHOW. I'm not sure this will help bring the focus to the top though. If that doesn't work then try the following. First off, do not use FindWindow(), it is unnecessarily unreliable

how to terminate a process created by CreateProcess()?

ⅰ亾dé卋堺 提交于 2019-12-01 02:25:30
I have created a process using CreateProcess() . This is the code: STARTUPINFO si = {0}; PROCESS_INFORMATION pi = {0}; result = CreateProcess("C:\\AP\\DatabaseBase\\dbntsrv.exe", NULL, NULL, NULL, FALSE, 0, NULL, "C:\\ADP\\SQLBase", &si, &pi) How can I get the Handle and processId of this specific process? And eventually use it to close this process? Thank You. HardCoder In the struct pi you get: typedef struct _PROCESS_INFORMATION { HANDLE hProcess; HANDLE hThread; DWORD dwProcessId; DWORD dwThreadId; } PROCESS_INFORMATION, *LPPROCESS_INFORMATION; The first parameter is the handle to the

Got “The system cannot find the file specified” when I run NETSH from CreateProcess but it works ok on Command Prompt?

怎甘沉沦 提交于 2019-11-30 22:25:52
I have an NT service that calls a console program written in Delphi 7, let's call it failover.exe that in turn calls NETSH using a procedure I found: procedure ExecConsoleApp(CommandLine: ansistring; Output, Errors: TStringList); Note: ExecConsoleApp uses CreateProcess, see the following link for full code: http://www.delphisources.ru/pages/faq/base/createprocess_console.html I would pass the following to CommandLine before calling ExecConsoleApp : cmd.exe /c "C:\Windows\system32\netsh.exe interface delete address "Wireless Network Connection" 192.168.0.36" ExecConsoleApp will return an error:

how to terminate a process created by CreateProcess()?

邮差的信 提交于 2019-11-30 22:00:10
问题 I have created a process using CreateProcess() . This is the code: STARTUPINFO si = {0}; PROCESS_INFORMATION pi = {0}; result = CreateProcess("C:\\AP\\DatabaseBase\\dbntsrv.exe", NULL, NULL, NULL, FALSE, 0, NULL, "C:\\ADP\\SQLBase", &si, &pi) How can I get the Handle and processId of this specific process? And eventually use it to close this process? Thank You. 回答1: In the struct pi you get: typedef struct _PROCESS_INFORMATION { HANDLE hProcess; HANDLE hThread; DWORD dwProcessId; DWORD

how to get the process output when using jna and CreateProcessW

ぐ巨炮叔叔 提交于 2019-11-30 19:43:32
问题 I'm trying to figure out how to read the standard out/err from the process I've created with CreateProcessW. I looked at the docs, googled and searched this list but I didn't find good pointers/samples yet :) Here's what I came up with so far (it's working fine on windows, it's a relevant snippet from my java code): Kernel32 kernel32 = (Kernel32) Native.loadLibrary("kernel32", Kernel32.class); Kernel32.StartupInfo startupInfo = new Kernel32.StartupInfo(); Kernel32.ProcessInfo

CreateProcess and ShellExecute differences

依然范特西╮ 提交于 2019-11-30 18:45:57
What are the main differences between the two? I'm willing to run only another EXE from my (C++) application. Are there any differences when inheriting environments, security features etc? The main difference between CreateProcess and ShellExecute is the following: CreateProcess is more oriented on low level and ShellExec on the high user lever which see the user in explorer. For example using of CreateProcess one can use command line which length is more as MAX_PATH . It has 32,768 characters restriction. You can also use CreateProcess to start program (if you have enough permissions) on

How to create a process that is not a child of it's creating process?

微笑、不失礼 提交于 2019-11-30 18:11:27
问题 I have two processes, A and B. At some point A creates B. After B is created, if A's process tree is killed, I want B to still be around. I am using CreateProcess() to create B, and I can't seem to find any way to make it create the process without it being a child. Same thing with ShellExecuteEx(), but I am probably missing some flag. Does anyone know what I could use to do this? EDIT: I forgot to mention that both processes need a HANDLE or process ID to the other 回答1: You can try that

CreateProcess and command line arguments

本小妞迷上赌 提交于 2019-11-30 15:23:05
Background Info: Windows 7, Visual C++ 2010 Express Problem: CreateProcess() keeps returning with 'Invalid command line argument' Explanation: I'm writing a piece of code that calls external programs using the Windows API's CreateProcess. I've gotten the call to work with one external program so far: if( !CreateProcess( "C:\\Temp\\convert.exe", t_str, // Arguments ... } //where t_str is " C:\\img1.jpeg C:\\img1.pgm" (ImageMagick if you're wondering). This works perfectly even with the amount of data-mangling I did to push everything into the Windows strings and pointers. So I copied all of the

CreateProcess and command line arguments

只愿长相守 提交于 2019-11-29 22:01:23
问题 Background Info: Windows 7, Visual C++ 2010 Express Problem: CreateProcess() keeps returning with 'Invalid command line argument' Explanation: I'm writing a piece of code that calls external programs using the Windows API's CreateProcess. I've gotten the call to work with one external program so far: if( !CreateProcess( "C:\\Temp\\convert.exe", t_str, // Arguments ... } //where t_str is " C:\\img1.jpeg C:\\img1.pgm" (ImageMagick if you're wondering). This works perfectly even with the amount

CreateProcess() Error

一笑奈何 提交于 2019-11-29 12:48:14
STARTUPINFO si; PROCESS_INFORMATION pi; memset(&si, 0, sizeof(si)); memset(&pi, 0, sizeof(pi)); si.cb = sizeof(si); LPCWSTR procName =(LPCWSTR)"D:\\test dir 1\\Calc.exe"; LPWSTR procArg =(LPWSTR)"blacknull"; if(CreateProcess(procName,procArg,0,0,0,CREATE_DEFAULT_ERROR_MODE,0,0,&si,&pi)) { //do some work } printf( "CreateProcess failed (%d).\n", GetLastError()); system("Pause"); It keeps throwing Error(2)-> The System cannot find the file specified . I don't know what's wrong. I also tried to use "Calc.exe" which in the same Dir. but it's not working. You use the L prefix to make a wide