From bc08232b2b0a3ca62ada8a175b9b6eda0dfdbc50 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 1 Mar 2019 10:29:42 +0100 Subject: [run-virt] Support setting printer as default by naming it @* --- .../data/opt/openslx/vmchooser/data/openslx.exe | Bin 57344 -> 58368 bytes core/modules/run-virt/winres/src/winres.c | 19 ++++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/data/openslx.exe b/core/modules/run-virt/data/opt/openslx/vmchooser/data/openslx.exe index 2e0aff80..af1d0bd1 100755 Binary files a/core/modules/run-virt/data/opt/openslx/vmchooser/data/openslx.exe and b/core/modules/run-virt/data/opt/openslx/vmchooser/data/openslx.exe differ diff --git a/core/modules/run-virt/winres/src/winres.c b/core/modules/run-virt/winres/src/winres.c index ca968cda..939739fb 100644 --- a/core/modules/run-virt/winres/src/winres.c +++ b/core/modules/run-virt/winres/src/winres.c @@ -993,9 +993,22 @@ static void postSuccessfulMount(const netdrive_t *d, wchar_t *letter) //int offs = (def ? 1 : 0); TODO } StringCchPrintfW(cmdline, MAX_PATH, L"printui.dll PrintUIEntry /q /in /n \"%s\"", wUncPath); - // TODO: Make sure COM is initialized - ShellExecuteW(NULL, L"open", L"rundll32", cmdline, NULL, SW_HIDE); - // TODO: Set default; need to wait for install to finish + SHELLEXECUTEINFOW e = {0}, f = {0}; + e.cbSize = sizeof(e); + e.lpFile = L"rundll32"; + e.lpParameters = cmdline; + e.nShow = SW_HIDE; + f = e; // Copy struct before we set the following flag for the first one + e.fMask = SEE_MASK_NOCLOSEPROCESS; // So we can wait for the first one + ShellExecuteExW(&e); + if (def) { // Only actually do so if we want to set it as default + WaitForSingleObject(e.hProcess, INFINITE); + } + CloseHandle(e.hProcess); + if (def) { + StringCchPrintfW(cmdline, MAX_PATH, L"printui.dll PrintUIEntry /q /y /n \"%s\"", wUncPath); + ShellExecuteExW(&f); + } } } -- cgit v1.2.3-55-g7522