-
Notifications
You must be signed in to change notification settings - Fork 0
/
WinKiosk.cpp
41 lines (34 loc) · 1.02 KB
/
WinKiosk.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <windows.h>
#include <shlobj.h>
#include <shlwapi.h>
#include <strsafe.h>
BOOL DoExecute(HWND hwnd, LPCWSTR pszCmd, INT nCmdShow)
{
WCHAR szText[256];
StringCbCopyW(szText, sizeof(szText), pszCmd);
WCHAR szPath[MAX_PATH];
GetModuleFileName(NULL, szPath, ARRAYSIZE(szPath));
*PathFindFileName(szPath) = 0;
STARTUPINFO si;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
si.wShowWindow = nCmdShow;
si.dwFlags = STARTF_USESHOWWINDOW;
PROCESS_INFORMATION pi;
ZeroMemory(&pi, sizeof(pi));
HANDLE hProcess;
BOOL ret = CreateProcessW(NULL, szText, NULL, NULL, TRUE, 0, NULL, szPath, &si, &pi);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
return ret;
}
INT WINAPI
WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
INT nCmdShow)
{
if (DoExecute(NULL, L"SimpleBrowser.exe --kiosk", SW_SHOWNORMAL))
return EXIT_SUCCESS;
return EXIT_FAILURE;
}