4 * Copyright 2006 Christian Gmeiner
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
31 #include "wine/test.h"
33 /* function pointers */
34 static HMODULE hSetupAPI;
35 static HDEVINFO (WINAPI *pSetupDiCreateDeviceInfoListExW)(GUID*,HWND,PCWSTR,PVOID);
36 static BOOL (WINAPI *pSetupDiDestroyDeviceInfoList)(HDEVINFO);
38 static void init_function_pointers(void)
40 hSetupAPI = LoadLibraryA("setupapi.dll");
44 pSetupDiCreateDeviceInfoListExW = (void *)GetProcAddress(hSetupAPI, "SetupDiCreateDeviceInfoListExW");
45 pSetupDiDestroyDeviceInfoList = (void *)GetProcAddress(hSetupAPI, "SetupDiDestroyDeviceInfoList");
49 static void test_SetupDiCreateDeviceInfoListEx(void)
54 static CHAR notnull[] = "NotNull";
55 static const WCHAR machine[] = { 'd','u','m','m','y',0 };
57 SetLastError(0xdeadbeef);
58 /* create empty DeviceInfoList, but set Reserved to a value, which is not NULL */
59 devlist = pSetupDiCreateDeviceInfoListExW(NULL, NULL, NULL, notnull);
61 error = GetLastError();
62 ok(devlist == INVALID_HANDLE_VALUE, "SetupDiCreateDeviceInfoListExW failed : %p %ld (expected %p)\n", devlist, error, INVALID_HANDLE_VALUE);
63 ok(error == ERROR_INVALID_PARAMETER, "GetLastError returned wrong value : %ld, (expected %d)\n", error, ERROR_INVALID_PARAMETER);
65 SetLastError(0xdeadbeef);
66 /* create empty DeviceInfoList, but set MachineName to something */
67 devlist = pSetupDiCreateDeviceInfoListExW(NULL, NULL, machine, NULL);
69 error = GetLastError();
70 ok(devlist == INVALID_HANDLE_VALUE, "SetupDiCreateDeviceInfoListExW failed : %p %ld (expected %p)\n", devlist, error, INVALID_HANDLE_VALUE);
71 ok(error == ERROR_INVALID_MACHINENAME, "GetLastError returned wrong value : %ld, (expected %d)\n", error, ERROR_INVALID_MACHINENAME);
73 /* create empty DeviceInfoList */
74 devlist = pSetupDiCreateDeviceInfoListExW(NULL, NULL, NULL, NULL);
75 ok(devlist && devlist != INVALID_HANDLE_VALUE, "SetupDiCreateDeviceInfoListExW failed : %p %ld (expected != %p)\n", devlist, error, INVALID_HANDLE_VALUE);
77 /* destroy DeviceInfoList */
78 ret = pSetupDiDestroyDeviceInfoList(devlist);
79 ok(ret, "SetupDiDestroyDeviceInfoList failed : %ld\n", error);
84 init_function_pointers();
88 if (pSetupDiCreateDeviceInfoListExW && pSetupDiDestroyDeviceInfoList)
89 test_SetupDiCreateDeviceInfoListEx();
91 trace("Needed calls not all available, skipping tests.\n");