UI가 필요한 응용 프로그램을 시작하는 프로세스를 만들려고합니다. 그래서 그것은 세션 0에있을 수 없습니다. 내 생각은 현재 로그온 한 사용자의 winlogon.exe 프로세스 ID를 얻는 것이 었습니다. 이 방법으로 나는 winlogon 토큰을 복제하고 CreateProcessAsUser 함수를 사용하여 응용 프로그램을 실행할 수 있습니다. 지금까지 내 코드 : (응용 프로그램은 내가 실행이 필요 할 때이 호출되고) 그래서 기본적으로winlogon.exe의 세션 ID 및 프로세스 ID를 얻으십시오.
#include <windows.h>
#include <tlhelp32.h>
#include <tchar.h>
this function()
{
HANDLE hProcessSnap;
HANDLE hProcess;
PROCESSENTRY32 pe32;
DWORD dwPriorityClass;
// Take a snapshot of all processes in the system.
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
// Set the size of the structure before using it.
pe32.dwSize = sizeof(PROCESSENTRY32);
//get the active session id
DWORD sessionID = WTSGetActiveConsoleSessionId();
// Now walk through the snapshot of processes
//I want to narrow this down to processes called winlogon
//if multiple users logged on system i want to make sure the active user
//will get the application run the their screen
do
{
// Retrieve the priority class.
dwPriorityClass = 0;
//here i want to compare the sessionID with session IDs of each winlogon process
//stuck for implementation here
//when i find a match i can use the processID to gain the token and create
//a duplicate so it can be used in CreateAsUser function.
}while(Process32Next(hProcessSnap, &pe32));
}
내가는 과정의 스냅 샷을 좁혀 도움을 필요로하는 세션을 통해 그냥 "Winlogon을"과 반복에 활성 사용자의 sessionID와 일치하는 이러한 프로세스의 ID. 미리 감사드립니다. D