Create a process in C
#include <stdlib.h>
#include <stdio.h>
#include <windows.h>
 
 
int main()
{
	STARTUPINFO startInfo;
	PROCESS_INFORMATION procInfo;
 
	//lock user
	WCHAR cmd[50] = L"rundll32.exe user32.dll, LockWorkStation\0";
 
	SecureZeroMemory(&startInfo, sizeof(startInfo));
	startInfo.cb = sizeof(startInfo);
	SecureZeroMemory(&procInfo, sizeof(procInfo));
 
	if (CreateProcess(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &startInfo, &procInfo) != 0)
		return GetLastError();
 
	CloseHandle(procInfo.hProcess);
	CloseHandle(procInfo.hThread);
 
	return EXIT_SUCCESS;
}
Categories: C Tags: , , ,
%d bloggers like this: