Commit 480b6495 authored by James Hawkins's avatar James Hawkins Committed by Alexandre Julliard

advpack: Implement the launching of executables in RunSetupCommand.

parent e4b31800
......@@ -156,6 +156,39 @@ HRESULT WINAPI LaunchINFSectionExA( HWND hWnd, HINSTANCE hInst, LPSTR cmdline, I
return E_FAIL;
}
static HRESULT launch_exe(LPCWSTR cmd, LPCWSTR dir, HANDLE *phEXE)
{
STARTUPINFOW si;
PROCESS_INFORMATION pi;
if (phEXE) *phEXE = NULL;
ZeroMemory(&pi, sizeof(pi));
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
if (!CreateProcessW(NULL, (LPWSTR)cmd, NULL, NULL, FALSE,
CREATE_DEFAULT_ERROR_MODE | CREATE_NEW_PROCESS_GROUP,
NULL, dir, &si, &pi))
{
return HRESULT_FROM_WIN32(GetLastError());
}
CloseHandle(pi.hThread);
if (phEXE)
{
*phEXE = pi.hProcess;
return S_ASYNCHRONOUS;
}
/* wait for the child process to finish */
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hProcess);
return S_OK;
}
/***********************************************************************
* RunSetupCommandA (ADVPACK.@)
*
......@@ -220,23 +253,26 @@ HRESULT WINAPI RunSetupCommandA(HWND hWnd, LPCSTR szCmdName,
* HRESULT_FROM_WIN32(GetLastError()) Some other error
*
* BUGS
* Unimplemented
* INF install unimplemented.
*/
HRESULT WINAPI RunSetupCommandW(HWND hWnd, LPCWSTR szCmdName,
LPCWSTR szInfSection, LPCWSTR szDir,
LPCWSTR lpszTitle, HANDLE *phEXE,
DWORD dwFlags, LPVOID pvReserved )
{
FIXME("(%p, %s, %s, %s, %s, %p, 0x%08lx, %p): stub\n",
TRACE("(%p, %s, %s, %s, %s, %p, 0x%08lx, %p)\n",
hWnd, debugstr_w(szCmdName), debugstr_w(szInfSection),
debugstr_w(szDir), debugstr_w(lpszTitle),
phEXE, dwFlags, pvReserved);
if (dwFlags)
FIXME("Unhandled flags: 0x%08lx\n", dwFlags);
if (!szCmdName || !szDir)
return E_INVALIDARG;
if (!(dwFlags & RSC_FLAG_INF))
*phEXE = NULL;
return launch_exe(szCmdName, szDir, phEXE);
return E_UNEXPECTED;
}
......@@ -56,22 +56,16 @@ static void test_RunSetupCommand()
/* try to run a non-existent exe */
hexe = (HANDLE)0xdeadbeef;
hr = pRunSetupCommand(NULL, "idontexist.exe", "Install", "c:\\windows\\system32", "Title", &hexe, 0, NULL);
todo_wine
{
ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND),
"Expected HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), got %ld\n", hr);
}
ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND),
"Expected HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), got %ld\n", hr);
ok(hexe == NULL, "Expcted hexe to be NULL\n");
ok(!TerminateProcess(hexe, 0), "Expected TerminateProcess to fail\n");
/* try a bad directory */
hexe = (HANDLE)0xdeadbeef;
hr = pRunSetupCommand(NULL, "winve.exe", "Install", "", "Title", &hexe, 0, NULL);
todo_wine
{
ok(hr == HRESULT_FROM_WIN32(ERROR_DIRECTORY),
"Expected HRESULT_FROM_WIN32(ERROR_DIRECTORY), got %ld\n", hr);
}
hr = pRunSetupCommand(NULL, "winver.exe", "Install", "non\\existent\\directory", "Title", &hexe, 0, NULL);
ok(hr == HRESULT_FROM_WIN32(ERROR_DIRECTORY),
"Expected HRESULT_FROM_WIN32(ERROR_DIRECTORY), got %ld\n", hr);
ok(hexe == NULL, "Expcted hexe to be NULL\n");
ok(!TerminateProcess(hexe, 0), "Expected TerminateProcess to fail\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment