advpack: Implement the launching of executables in RunSetupCommand.

oldstable
James Hawkins 2006-03-26 22:05:58 -06:00 committed by Alexandre Julliard
parent e4b31800ab
commit 480b64950b
2 changed files with 44 additions and 14 deletions

View File

@ -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;
}

View File

@ -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");