powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / C++ [игнор отключен] [закрыт для гостей] / CreateProcess и его хендл
6 сообщений из 6, страница 1 из 1
CreateProcess и его хендл
    #33384722
dishlo
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Запускаю новый процесс, хочу иметь его хендл и передавать ему сообщения с попощью SendMessage.

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
		STARTUPINFO si;
		PROCESS_INFORMATION pi;
		int Rc;

		memset(&si,  0 , sizeof(si));
		si.cb = sizeof(si);
		si.dwFlags = STARTF_USESHOWWINDOW;
		si.wShowWindow = SW_HIDE;
		


	//	 Rc = CreateProcess("C:\\text.bat ", NULL, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi);
		Rc = CreateProcess("C:\\AllProjects\\vnc_winsrc\\vncviewer\\Debug\\vncviewer.exe ", NULL, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi);
		if (!Rc) {
			MessageBox( 0 ,"Ошибка запуска", "Ошибка", MB_OK);
		} // if
		VCRApp = OpenProcess( NULL, NULL, pi.dwProcessId);

VCRApp - должен быть его хендл, но он всегда 0, хотя программа открывается.
Что я делаю не так?
...
Рейтинг: 0 / 0
CreateProcess и его хендл
    #33384726
Карабас Барабас
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
GetLastError ?
Posted via ActualForum NNTP Server 1.3
...
Рейтинг: 0 / 0
CreateProcess и его хендл
    #33384733
Карабас Барабас
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
dwDesiredAccess = NULL ???????
bInheritHandle = NULL тоже ???? хотя 2-е не строго
Posted via ActualForum NNTP Server 1.3
...
Рейтинг: 0 / 0
CreateProcess и его хендл
    #33384760
dishlo
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
вообще те у меня в MSDN написано, так что я на них забил

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
HANDLE OpenProcess( 
DWORD fdwAccess, 
BOOL fInherit, 
DWORD IDProcess);
Parameters 

fdwAccess 
Not supported; set to zero. 
fInherit 
Not supported; set to FALSE. 
IDProcess 
Specifies the process identifier of the process to open.

GetLastError = 5
...
Рейтинг: 0 / 0
CreateProcess и его хендл
    #33384811
Карабас Барабас
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
хм, странно, а у меня в бильдеровской справке по win32 вот что:
Win32 developer's referencesThe OpenProcess function returns a handle of an existing process object.

HANDLE OpenProcess(

DWORD dwDesiredAccess, // access flag
BOOL bInheritHandle, // handle inheritance flag
DWORD dwProcessId // process identifier
);


Parameters

dwDesiredAccess

Specifies the access to the process object. For operating systems that support security checking, this access is checked against any security descriptor for the target process. Any combination of the following access flags can be specified in addition to the STANDARD_RIGHTS_REQUIRED access flags:

Access Description
PROCESS_ALL_ACCESS Specifies all possible access flags for the process object.
PROCESS_CREATE_PROCESS Used internally.
PROCESS_CREATE_THREAD Enables using the process handle in the CreateRemoteThread function to create a thread in the process.
PROCESS_DUP_HANDLE Enables using the process handle as either the source or target process in the DuplicateHandle function to duplicate a handle.
PROCESS_QUERY_INFORMATION Enables using the process handle in the GetExitCodeProcess and GetPriorityClass functions to read information from the process object.
PROCESS_SET_INFORMATION Enables using the process handle in the SetPriorityClass function to set the priority class of the process.
PROCESS_TERMINATE Enables using the process handle in the TerminateProcess function to terminate the process.
PROCESS_VM_OPERATION Enables using the process handle in the VirtualProtectEx and WriteProcessMemory functions to modify the virtual memory of the process.
PROCESS_VM_READ Enables using the process handle in the ReadProcessMemory function to read from the virtual memory of the process.
PROCESS_VM_WRITE Enables using the process handle in the WriteProcessMemory function to write to the virtual memory of the process.
SYNCHRONIZE Windows NT only: Enables using the process handle in any of the wait functions to wait for the process to terminate.


bInheritHandle

Specifies whether the returned handle can be inherited by a new process created by the current process. If TRUE, the handle is inheritable.

dwProcessId

Specifies the process identifier of the process to open.



Return Values

If the function succeeds, the return value is an open handle of the specified process.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.

Remarks

The handle returned by the OpenProcess function can be used in any function that requires a handle to a process, such as the wait functions, provided the appropriate access rights were requested.
When you are finished with the handle, be sure to close it using the CloseHandle function.

See Also

CloseHandle, CreateProcess, CreateRemoteThread, DuplicateHandle, GetCurrentProcess, GetCurrentProcessId, GetExitCodeProcess, GetPriorityClass, ReadProcessMemory, SetPriorityClass, TerminateProcess, VirtualProtectEx, WriteProcessMemory
Posted via ActualForum NNTP Server 1.3
...
Рейтинг: 0 / 0
CreateProcess и его хендл
    #33385676
ska
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
dishloVCRApp - должен быть его хендл, но он всегда 0, хотя программа открывается.


Не совсем ответ на вопрос, но чем pi.hProcess не устраивает ?
...
Рейтинг: 0 / 0
6 сообщений из 6, страница 1 из 1
Форумы / C++ [игнор отключен] [закрыт для гостей] / CreateProcess и его хендл
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]