2 * Unit tests for advpack.dll install functions
4 * Copyright (C) 2006 James Hawkins
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include "wine/test.h"
27 /* function pointers */
28 static HRESULT (WINAPI
*pRunSetupCommand
)(HWND
, LPCSTR
, LPCSTR
, LPCSTR
, LPCSTR
, HANDLE
*, DWORD
, LPVOID
);
30 static BOOL
init_function_pointers()
32 HMODULE hAdvPack
= LoadLibraryA("advpack.dll");
36 pRunSetupCommand
= (void *)GetProcAddress(hAdvPack
, "RunSetupCommand");
38 if (!pRunSetupCommand
)
44 static void test_RunSetupCommand()
49 /* try an invalid cmd name */
50 hr
= pRunSetupCommand(NULL
, NULL
, "Install", "Dir", "Title", NULL
, 0, NULL
);
51 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got %ld\n", hr
);
53 /* try an invalid directory */
54 hr
= pRunSetupCommand(NULL
, "winver.exe", "Install", NULL
, "Title", NULL
, 0, NULL
);
55 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got %ld\n", hr
);
57 /* try to run a non-existent exe */
59 hr
= pRunSetupCommand(NULL
, "idontexist.exe", "Install", "c:\\windows\\system32", "Title", &hexe
, 0, NULL
);
62 ok(hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
),
63 "Expected HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), got %ld\n", hr
);
65 ok(hexe
== NULL
, "Expcted hexe to be NULL\n");
66 ok(!TerminateProcess(hexe
, 0), "Expected TerminateProcess to fail\n");
68 /* try a bad directory */
70 hr
= pRunSetupCommand(NULL
, "winver.exe", "Install", "windows\\system32", "Title", &hexe
, 0, NULL
);
73 ok(hr
== HRESULT_FROM_WIN32(ERROR_DIRECTORY
),
74 "Expected HRESULT_FROM_WIN32(ERROR_DIRECTORY), got %ld\n", hr
);
76 ok(hexe
== NULL
, "Expcted hexe to be NULL\n");
77 ok(!TerminateProcess(hexe
, 0), "Expected TerminateProcess to fail\n");
79 /* try to run an exe with the RSC_FLAG_INF flag */
81 hr
= pRunSetupCommand(NULL
, "winver.exe", "Install", "c:\\windows\\system32", "Title", &hexe
, RSC_FLAG_INF
, NULL
);
84 ok(hr
== SPAPI_E_WRONG_INF_STYLE
, "Expected SPAPI_E_WRONG_INF_STYLE, got %ld\n", hr
);
86 ok(hexe
== NULL
, "Expected hexe to be NULL\n");
87 ok(!TerminateProcess(hexe
, 0), "Expected TerminateProcess to fail\n");
91 hr
= pRunSetupCommand(NULL
, "winver.exe", "Install", "c:\\windows\\system32", "Title", &hexe
, 0, NULL
);
94 ok(hr
== S_ASYNCHRONOUS
, "Expected S_ASYNCHRONOUS, got %ld\n", hr
);
95 ok(hexe
!= NULL
, "Expected hexe to be non-NULL\n");
96 ok(TerminateProcess(hexe
, 0), "Expected TerminateProcess to succeed\n");
102 if (!init_function_pointers())
105 test_RunSetupCommand();