4 * Copyright 2006 Stefan Leichter
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
21 #include "wine/test.h"
25 #define FLOPPY "FLOPPY"
26 #define HARDISK "HARDDISK"
27 #define LANMAN "LANMANREDIRECTOR"
28 #define RAMDISK "RAMDISK"
30 static HINSTANCE hdll;
31 static BOOL (WINAPI * pGetVolumeNameForVolumeMountPointA)(LPCSTR, LPSTR, DWORD);
32 static BOOL (WINAPI * pGetVolumeNameForVolumeMountPointW)(LPCWSTR, LPWSTR, DWORD);
34 /* ############################### */
36 static void test_query_dos_deviceA(void)
38 char drivestr[] = "a:";
39 char *p, buffer[2000];
41 for (;drivestr[0] <= 'z'; drivestr[0]++) {
42 ret = QueryDosDeviceA( drivestr, buffer, sizeof(buffer));
44 for (p = buffer; *p; p++) *p = toupper(*p);
46 ok( strstr( buffer, CDROM) || strstr( buffer, FLOPPY) ||
47 strstr( buffer, HARDISK) || strstr( buffer, LANMAN) ||
48 strstr( buffer, RAMDISK), "expect the string %s contains %s,%s,%s,%s or %s\n",
49 buffer, CDROM, FLOPPY, HARDISK, LANMAN, RAMDISK);
54 static void test_GetVolumeNameForVolumeMountPointA(void)
57 char volume[MAX_PATH], path[] = "c:\\";
58 DWORD len = sizeof(volume);
60 /* not present before w2k */
61 if (!pGetVolumeNameForVolumeMountPointA) {
62 skip("GetVolumeNameForVolumeMountPointA not found\n");
66 ret = pGetVolumeNameForVolumeMountPointA(path, volume, 0);
67 ok(ret == FALSE, "GetVolumeNameForVolumeMountPointA succeeded\n");
69 if (0) { /* these crash on XP */
70 ret = pGetVolumeNameForVolumeMountPointA(path, NULL, len);
71 ok(ret == FALSE, "GetVolumeNameForVolumeMountPointA succeeded\n");
73 ret = pGetVolumeNameForVolumeMountPointA(NULL, volume, len);
74 ok(ret == FALSE, "GetVolumeNameForVolumeMountPointA succeeded\n");
77 ret = pGetVolumeNameForVolumeMountPointA(path, volume, len);
78 ok(ret == TRUE, "GetVolumeNameForVolumeMountPointA failed\n");
81 static void test_GetVolumeNameForVolumeMountPointW(void)
84 WCHAR volume[MAX_PATH], path[] = {'c',':','\\',0};
85 DWORD len = sizeof(volume) / sizeof(WCHAR);
87 /* not present before w2k */
88 if (!pGetVolumeNameForVolumeMountPointW) {
89 skip("GetVolumeNameForVolumeMountPointW not found\n");
93 ret = pGetVolumeNameForVolumeMountPointW(path, volume, 0);
94 ok(ret == FALSE, "GetVolumeNameForVolumeMountPointA succeeded\n");
96 if (0) { /* these crash on XP */
97 ret = pGetVolumeNameForVolumeMountPointW(path, NULL, len);
98 ok(ret == FALSE, "GetVolumeNameForVolumeMountPointW succeeded\n");
100 ret = pGetVolumeNameForVolumeMountPointW(NULL, volume, len);
101 ok(ret == FALSE, "GetVolumeNameForVolumeMountPointW succeeded\n");
104 ret = pGetVolumeNameForVolumeMountPointW(path, volume, len);
105 ok(ret == TRUE, "GetVolumeNameForVolumeMountPointW failed\n");
110 hdll = GetModuleHandleA("kernel32.dll");
111 pGetVolumeNameForVolumeMountPointA = (void *) GetProcAddress(hdll, "GetVolumeNameForVolumeMountPointA");
112 pGetVolumeNameForVolumeMountPointW = (void *) GetProcAddress(hdll, "GetVolumeNameForVolumeMountPointW");
114 test_query_dos_deviceA();
115 test_GetVolumeNameForVolumeMountPointA();
116 test_GetVolumeNameForVolumeMountPointW();