big patch to implement SetupPromptForDisk (please comment)

Ricardo Filipe ricardo_barbano at hotmail.com
Mon Feb 16 16:56:19 CST 2009


hello guys.
i have took the endeavour of making my first dialog patch, managed to do it
this weekend, to implement SetupPromptForDisk, which i stubbed but had some
problems on the stub. gave me some big headaches to make this work x)

so here is the patch, i've made the two versions of the dialog, but before
submiting i'd like your comments on it.
what is wrong in it? in which file should it be? i left it in stubs.c but i
think misc.c might be a better place.
is it  testable? i once asked this on IRC and got a "no" for response, is it
not testable?
should i put some comments? code documentation (or lack there of) is a flaw
of mine...

i'm hoping for your replies so that i can submit as soon as possible.
i've made some tests for "manual" testing and i have tested in "A vampire
Story", the game that needed the stub, and it all worked fine. yhey!
it lacks LOTS of details though, i just implemented the juice of it and some
simple details.

regards.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.winehq.org/pipermail/wine-devel/attachments/20090216/9b758ae0/attachment-0001.htm 
-------------- next part --------------
From 80a9d7e2031153ec296638dcc60fb9475e111572 Mon Sep 17 00:00:00 2001
From: Ricardo Filipe <ricardo_barbano at hotmail.com>
Date: Mon, 16 Feb 2009 20:59:13 +0000
Subject: setupapi: implement SetupPromptForDiskA/W

---
 dlls/setupapi/En.rc              |   25 +++-
 dlls/setupapi/Makefile.in        |    2 +-
 dlls/setupapi/setupapi_private.h |   11 ++
 dlls/setupapi/stubs.c            |  331 +++++++++++++++++++++++++++++++++++++-
 dlls/setupapi/tests/misc.c       |   28 ++++
 include/setupapi.h               |   16 ++-
 6 files changed, 401 insertions(+), 12 deletions(-)

diff --git a/dlls/setupapi/En.rc b/dlls/setupapi/En.rc
index 5d45feb..04261ac 100644
--- a/dlls/setupapi/En.rc
+++ b/dlls/setupapi/En.rc
@@ -2,7 +2,8 @@
  * English resources for SETUPAPI
  *
  * Copyright 2001 Andreas Mohr
- *
+ * Copyright 2009 Ricardo Filipe
+ * 
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
@@ -20,6 +21,14 @@
 
 LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
 
+STRINGTABLE DISCARDABLE
+{
+        IDS_PROMPTDISK   "The file '%s' on %s is needed"
+        IDS_UNKNOWN      "Unknown"
+        IDS_COPYFROM     "Copy files from:"
+        IDS_INFO         "Type the path where the file is located, and then click OK."
+}
+
 COPYFILEDLGORD DIALOG LOADONCALL MOVEABLE DISCARDABLE 20, 20, 208, 105
 STYLE DS_MODALFRAME | DS_SETFONT | WS_POPUP | WS_VISIBLE | WS_CAPTION
 CAPTION "Copying Files..."
@@ -32,3 +41,17 @@ BEGIN
 	LTEXT "", DESTSTRORD, 7, 41, 194, 22, WS_CHILD | WS_VISIBLE | WS_GROUP
 	CONTROL "", PROGRESSORD, "setupx_progress", 7, 63, 194, 13, WS_CHILD | WS_VISIBLE | WS_TABSTOP
 END
+
+IDPROMPTFORDISK DIALOG MOVEABLE DISCARDABLE 0, 0, 250, 120
+STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
+CAPTION "Files Needed"
+FONT 8, "MS Shell Dlg"
+BEGIN
+	LTEXT "Insert the manufacturer's installation disk, and then\nmake sure the correct drive is selected below", IDC_FILENEEDED, 10, 10, 175, 22, WS_CHILD | WS_VISIBLE | WS_GROUP
+	LTEXT "", IDC_INFO, 10, 50, 175, 22, WS_CHILD | WS_VISIBLE | WS_GROUP
+	LTEXT "Copy manufacturer's files from:", IDC_COPYFROM, 10, 90, 175, 11, WS_CHILD | WS_VISIBLE | WS_GROUP
+        CONTROL "", IDC_PATH, "COMBOBOX", WS_TABSTOP | WS_GROUP | WS_VSCROLL | WS_VISIBLE | CBS_DISABLENOSCROLL | CBS_AUTOHSCROLL | CBS_DROPDOWN, 10, 100, 175, 14
+	PUSHBUTTON "OK", IDOK, 195, 10, 50, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
+	PUSHBUTTON "Cancel", IDCANCEL, 195, 30, 50, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
+        PUSHBUTTON "Browse...", IDC_RUNDLG_BROWSE, 195, 100, 50, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
+END
diff --git a/dlls/setupapi/Makefile.in b/dlls/setupapi/Makefile.in
index e6d3e80..8fe416d 100644
--- a/dlls/setupapi/Makefile.in
+++ b/dlls/setupapi/Makefile.in
@@ -5,7 +5,7 @@ SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = setupapi.dll
 IMPORTLIB = setupapi
-IMPORTS   = uuid user32 version advapi32 rpcrt4 kernel32 ntdll
+IMPORTS   = uuid user32 version advapi32 rpcrt4 kernel32 ntdll comdlg32
 DELAYIMPORTS = shell32 wintrust ole32 winspool
 
 C_SRCS = \
diff --git a/dlls/setupapi/setupapi_private.h b/dlls/setupapi/setupapi_private.h
index d01edba..0104f6b 100644
--- a/dlls/setupapi/setupapi_private.h
+++ b/dlls/setupapi/setupapi_private.h
@@ -24,6 +24,17 @@
 #define DESTSTRORD	501
 #define PROGRESSORD	502
 
+#define IDPROMPTFORDISK   1001
+#define IDC_FILENEEDED    503
+#define IDC_INFO          504
+#define IDC_COPYFROM      505
+#define IDC_PATH          506
+#define IDC_RUNDLG_BROWSE 507
+
+#define IDS_PROMPTDISK  508
+#define IDS_UNKNOWN     509
+#define IDS_COPYFROM    510
+#define IDS_INFO        511
 
 #define REG_INSTALLEDFILES "System\\CurrentControlSet\\Control\\InstalledFiles"
 #define REGPART_RENAME "\\Rename"
diff --git a/dlls/setupapi/stubs.c b/dlls/setupapi/stubs.c
index 4db264b..1ce0e66 100644
--- a/dlls/setupapi/stubs.c
+++ b/dlls/setupapi/stubs.c
@@ -19,6 +19,7 @@
  */
 
 #include <stdarg.h>
+#include <stdio.h>
 
 #include "wine/debug.h"
 #include "windef.h"
@@ -26,12 +27,42 @@
 #include "wingdi.h"
 #include "winuser.h"
 #include "winreg.h"
+#include "commdlg.h"
 #include "cfgmgr32.h"
 #include "setupapi.h"
 #include "winnls.h"
+#include "setupapi_private.h"
+
+#include "wine/unicode.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(setupapi);
 
+static HINSTANCE SETUPAPI_hInstance = 0;
+
+struct PromptDiskParamsA {
+    PCSTR DialogTitle;
+    PCSTR DiskName;
+    PCSTR PathToSource;
+    PCSTR FileSought;
+    PCSTR TagFile;
+    DWORD DiskPromptStyle;
+    PSTR PathBuffer;
+    DWORD PathBufferSize;
+    PDWORD PathRequiredSize;
+};
+
+struct PromptDiskParamsW {
+    PCWSTR DialogTitle;
+    PCWSTR DiskName;
+    PCWSTR PathToSource;
+    PCWSTR FileSought;
+    PCWSTR TagFile;
+    DWORD DiskPromptStyle;
+    PWSTR PathBuffer;
+    DWORD PathBufferSize;
+    PDWORD PathRequiredSize;
+};
+
 /***********************************************************************
  *		TPWriteProfileString (SETUPX.62)
  */
@@ -246,6 +277,244 @@ BOOL WINAPI SetupDiGetClassImageList(PSP_CLASSIMAGELIST_DATA ClassImageListData)
     return FALSE;
 }
 
+static void PromptDiskInitA(HWND hwnd, struct PromptDiskParamsA *params)
+{
+    CHAR format[256];
+    CHAR message[256];
+
+    SetWindowLongPtrA(hwnd, DWLP_USER, (LONG_PTR)params);
+
+    if(params->DialogTitle)
+        SetWindowTextA(hwnd, params->DialogTitle);
+    if(params->PathToSource)
+        SetDlgItemTextA(hwnd, IDC_PATH, params->PathToSource);
+
+    if(!(params->DiskPromptStyle & IDF_OEMDISK))
+    {
+        LoadStringA(SETUPAPI_hInstance, IDS_PROMPTDISK, format, sizeof(format)/sizeof(format[0]));
+
+        if(params->DiskName)
+            snprintf(message, sizeof(message)/sizeof(message[0]), format, params->FileSought, params->DiskName);
+        else
+        {
+            CHAR unknown[256];
+            LoadStringA(SETUPAPI_hInstance, IDS_UNKNOWN, unknown, sizeof(unknown)/sizeof(unknown[0]));
+            snprintf(message, sizeof(message)/sizeof(message[0]), format, params->FileSought, unknown);
+        }
+        SetDlgItemTextA(hwnd, IDC_FILENEEDED, message);
+
+        LoadStringA(SETUPAPI_hInstance, IDS_INFO, message, sizeof(message)/sizeof(message[0]));
+        SetDlgItemTextA(hwnd, IDC_INFO, message);
+        LoadStringA(SETUPAPI_hInstance, IDS_COPYFROM, message, sizeof(message)/sizeof(message[0]));
+        SetDlgItemTextA(hwnd, IDC_COPYFROM, message);
+    }
+    if(params->DiskPromptStyle & IDF_NOBROWSE)
+        ShowWindow(GetDlgItem(hwnd, IDC_RUNDLG_BROWSE), SW_HIDE);
+}
+
+static void PromptDiskOkA(HWND hwnd, struct PromptDiskParamsA *params)
+{
+    int requiredSize;
+    CHAR aux[MAX_PATH];
+    GetWindowTextA(GetDlgItem(hwnd, IDC_PATH), aux, MAX_PATH);
+    requiredSize = lstrlenA(aux)+1;
+
+    if(params->PathRequiredSize)
+    {
+        *params->PathRequiredSize = requiredSize;
+        TRACE("returning PathRequiredSize=%d\n",*params->PathRequiredSize);
+    }
+    if(!params->PathBuffer && !params->PathBufferSize)
+    {
+        EndDialog(hwnd, NO_ERROR);
+        return;
+    }
+    if(requiredSize > params->PathBufferSize || params->PathBufferSize < MAX_PATH)
+    {
+        EndDialog(hwnd, DPROMPT_BUFFERTOOSMALL);
+        return;
+    }
+    lstrcpyA(params->PathBuffer, aux);
+    TRACE("returning PathBuffer=%s\n", debugstr_a(params->PathBuffer));
+    EndDialog(hwnd, DPROMPT_SUCCESS);
+}
+
+static void PromptDiskBrowseA(HWND hwnd, struct PromptDiskParamsA *params)
+{
+    OPENFILENAMEA ofn;
+    ZeroMemory(&ofn, sizeof(ofn));
+
+    ofn.lStructSize = sizeof(ofn);
+    ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST;
+    ofn.hwndOwner = hwnd;
+    ofn.nMaxFile = MAX_PATH;
+    ofn.lpstrFile = HeapAlloc(GetProcessHeap(), 0, MAX_PATH*sizeof(CHAR));
+    lstrcpyA(ofn.lpstrFile, params->FileSought);
+
+    if(GetOpenFileNameA(&ofn))
+    {
+        CHAR* last_slash = strrchr(ofn.lpstrFile, '\\');
+        CHAR path[MAX_PATH];
+        *last_slash = 0;
+        lstrcpyA(path, ofn.lpstrFile);
+        SetDlgItemTextA(hwnd, IDC_PATH, path);
+    }
+    HeapFree(GetProcessHeap(), 0, ofn.lpstrFile);
+}
+
+static INT_PTR CALLBACK promptdisk_procA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+    switch(msg)
+    {
+        case WM_INITDIALOG:
+            PromptDiskInitA(hwnd, (struct PromptDiskParamsA *)lParam);
+            return TRUE;
+
+        case WM_COMMAND:
+            switch(wParam)
+            {
+                case IDOK:
+                {
+                    struct PromptDiskParamsA *params = 
+                        (struct PromptDiskParamsA *)GetWindowLongPtrA(hwnd, DWLP_USER);
+                    PromptDiskOkA(hwnd, params);
+                    return TRUE;
+                }
+                case IDCANCEL:
+                    EndDialog(hwnd, DPROMPT_CANCEL);
+                    return TRUE;
+
+                case IDC_RUNDLG_BROWSE:
+                {
+                    struct PromptDiskParamsA *params = 
+                        (struct PromptDiskParamsA *)GetWindowLongPtrA(hwnd, DWLP_USER);
+                    PromptDiskBrowseA(hwnd, params);
+                    return TRUE;
+                }
+            }
+    }
+    return FALSE;
+}
+
+static void PromptDiskInitW(HWND hwnd, struct PromptDiskParamsW *params)
+{
+    WCHAR format[256];
+    WCHAR message[256];
+
+    SetWindowLongPtrW(hwnd, DWLP_USER, (LONG_PTR)params);
+
+    if(params->DialogTitle)
+        SetWindowTextW(hwnd, params->DialogTitle);
+    if(params->PathToSource)
+        SetDlgItemTextW(hwnd, IDC_PATH, params->PathToSource);
+
+    if(!(params->DiskPromptStyle & IDF_OEMDISK))
+    {
+        LoadStringW(SETUPAPI_hInstance, IDS_PROMPTDISK, format, sizeof(format)/sizeof(format[0]));
+
+        if(params->DiskName)
+            snprintfW(message, sizeof(message)/sizeof(message[0]), format, params->FileSought, params->DiskName);
+        else
+        {
+            WCHAR unknown[256];
+            LoadStringW(SETUPAPI_hInstance, IDS_UNKNOWN, unknown, sizeof(unknown)/sizeof(unknown[0]));
+            snprintfW(message, sizeof(message)/sizeof(message[0]), format, params->FileSought, unknown);
+        }
+        SetDlgItemTextW(hwnd, IDC_FILENEEDED, message);
+
+        LoadStringW(SETUPAPI_hInstance, IDS_INFO, message, sizeof(message)/sizeof(message[0]));
+        SetDlgItemTextW(hwnd, IDC_INFO, message);
+        LoadStringW(SETUPAPI_hInstance, IDS_COPYFROM, message, sizeof(message)/sizeof(message[0]));
+        SetDlgItemTextW(hwnd, IDC_COPYFROM, message);
+    }
+    if(params->DiskPromptStyle & IDF_NOBROWSE)
+        ShowWindow(GetDlgItem(hwnd, IDC_RUNDLG_BROWSE), SW_HIDE);
+}
+
+static void PromptDiskOkW(HWND hwnd, struct PromptDiskParamsW *params)
+{
+    int requiredSize;
+    WCHAR aux[MAX_PATH];
+    GetWindowTextW(GetDlgItem(hwnd, IDC_PATH), aux, MAX_PATH);
+    requiredSize = lstrlenW(aux)+1;
+
+    if(params->PathRequiredSize)
+    {
+        *params->PathRequiredSize = requiredSize;
+        TRACE("returning PathRequiredSize=%d\n",*params->PathRequiredSize);
+    }
+    if(!params->PathBuffer && !params->PathBufferSize)
+    {
+        EndDialog(hwnd, NO_ERROR);
+        return;
+    }
+    if(requiredSize > params->PathBufferSize || params->PathBufferSize < MAX_PATH)
+    {
+        EndDialog(hwnd, DPROMPT_BUFFERTOOSMALL);
+        return;
+    }
+    lstrcpyW(params->PathBuffer, aux);
+    TRACE("returning PathBuffer=%s\n", debugstr_w(params->PathBuffer));
+    EndDialog(hwnd, DPROMPT_SUCCESS);
+}
+
+static void PromptDiskBrowseW(HWND hwnd, struct PromptDiskParamsW *params)
+{
+    OPENFILENAMEW ofn;
+    ZeroMemory(&ofn, sizeof(ofn));
+
+    ofn.lStructSize = sizeof(ofn);
+    ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST;
+    ofn.hwndOwner = hwnd;
+    ofn.nMaxFile = MAX_PATH;
+    ofn.lpstrFile = HeapAlloc(GetProcessHeap(), 0, MAX_PATH*sizeof(WCHAR));
+    lstrcpyW(ofn.lpstrFile, params->FileSought);
+
+    if(GetOpenFileNameW(&ofn))
+    {
+        WCHAR* last_slash = strrchrW(ofn.lpstrFile, '\\');
+        WCHAR path[MAX_PATH];
+        *last_slash = 0;
+        lstrcpyW(path, ofn.lpstrFile);
+        SetDlgItemTextW(hwnd, IDC_PATH, path);
+    }
+    HeapFree(GetProcessHeap(), 0, ofn.lpstrFile);
+}
+
+static INT_PTR CALLBACK promptdisk_procW(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+    switch(msg)
+    {
+        case WM_INITDIALOG:
+            PromptDiskInitW(hwnd, (struct PromptDiskParamsW *)lParam);
+            return TRUE;
+
+        case WM_COMMAND:
+            switch(wParam)
+            {
+                case IDOK:
+                {
+                    struct PromptDiskParamsW *params = 
+                        (struct PromptDiskParamsW *)GetWindowLongPtrW(hwnd, DWLP_USER);
+                    PromptDiskOkW(hwnd, params);
+                    return TRUE;
+                }
+                case IDCANCEL:
+                    EndDialog(hwnd, DPROMPT_CANCEL);
+                    return TRUE;
+
+                case IDC_RUNDLG_BROWSE:
+                {
+                    struct PromptDiskParamsW *params = 
+                        (struct PromptDiskParamsW *)GetWindowLongPtrW(hwnd, DWLP_USER);
+                    PromptDiskBrowseW(hwnd, params);
+                    return TRUE;
+                }
+            }
+    }
+    return FALSE;
+}
+
 /***********************************************************************
  *      SetupPromptForDiskA (SETUPAPI.@)
  */
@@ -253,11 +522,38 @@ UINT WINAPI SetupPromptForDiskA(HWND hwndParent, PCSTR DialogTitle, PCSTR DiskNa
         PCSTR PathToSource, PCSTR FileSought, PCSTR TagFile, DWORD DiskPromptStyle,
         PSTR PathBuffer, DWORD PathBufferSize, PDWORD PathRequiredSize)
 {
-    FIXME("%p %s %s %s %s %s %d %p %d %p: stub\n", hwndParent, debugstr_a(DialogTitle),
+    struct PromptDiskParamsA params;
+
+    TRACE("%p, %s, %s, %s, %s, %s, 0x%08x, %p, %d, %p\n", hwndParent, debugstr_a(DialogTitle),
           debugstr_a(DiskName), debugstr_a(PathToSource), debugstr_a(FileSought),
           debugstr_a(TagFile), DiskPromptStyle, PathBuffer, PathBufferSize,
           PathRequiredSize);
-    return 0;
+
+    if(!FileSought)
+    {
+        SetLastError(ERROR_INVALID_PARAMETER);
+        return DPROMPT_CANCEL;
+    }
+    if (!SETUPAPI_hInstance)
+    {
+        SETUPAPI_hInstance = GetModuleHandleA("setupapi.dll");
+        if (!SETUPAPI_hInstance)
+        {
+            ERR("Could not load sibling setupapi.dll\n");
+            return DPROMPT_CANCEL;
+        }
+    }
+    params.DialogTitle = DialogTitle;
+    params.DiskName = DiskName;
+    params.PathToSource = PathToSource;
+    params.FileSought = FileSought;
+    params.TagFile = TagFile;
+    params.DiskPromptStyle = DiskPromptStyle;
+    params.PathBuffer = PathBuffer;
+    params.PathBufferSize = PathBufferSize;
+    params.PathRequiredSize = PathRequiredSize;
+
+    return DialogBoxParamA(SETUPAPI_hInstance, MAKEINTRESOURCEA(IDPROMPTFORDISK), hwndParent, promptdisk_procA, (LPARAM)&params);
 }
 
 /***********************************************************************
@@ -267,11 +563,38 @@ UINT WINAPI SetupPromptForDiskW(HWND hwndParent, PCWSTR DialogTitle, PCWSTR Disk
         PCWSTR PathToSource, PCWSTR FileSought, PCWSTR TagFile, DWORD DiskPromptStyle,
         PWSTR PathBuffer, DWORD PathBufferSize, PDWORD PathRequiredSize)
 {
-    FIXME("%p %s %s %s %s %s %d %p %d %p: stub\n", hwndParent, debugstr_w(DialogTitle),
+    struct PromptDiskParamsW params;
+
+    TRACE("%p, %s, %s, %s, %s, %s, 0x%08x, %p, %d, %p\n", hwndParent, debugstr_w(DialogTitle),
           debugstr_w(DiskName), debugstr_w(PathToSource), debugstr_w(FileSought),
           debugstr_w(TagFile), DiskPromptStyle, PathBuffer, PathBufferSize,
           PathRequiredSize);
-    return 0;
+
+    if(!FileSought)
+    {
+        SetLastError(ERROR_INVALID_PARAMETER);
+        return DPROMPT_CANCEL;
+    }
+    if (!SETUPAPI_hInstance)
+    {
+        SETUPAPI_hInstance = GetModuleHandleA("setupapi.dll");
+        if (!SETUPAPI_hInstance)
+        {
+            ERR("Could not load sibling setupapi.dll\n");
+            return DPROMPT_CANCEL;
+        }
+    }
+    params.DialogTitle = DialogTitle;
+    params.DiskName = DiskName;
+    params.PathToSource = PathToSource;
+    params.FileSought = FileSought;
+    params.TagFile = TagFile;
+    params.DiskPromptStyle = DiskPromptStyle;
+    params.PathBuffer = PathBuffer;
+    params.PathBufferSize = PathBufferSize;
+    params.PathRequiredSize = PathRequiredSize;
+
+    return DialogBoxParamW(SETUPAPI_hInstance, MAKEINTRESOURCEW(IDPROMPTFORDISK), hwndParent, promptdisk_procW, (LPARAM)&params);
 }
 
 /***********************************************************************
diff --git a/dlls/setupapi/tests/misc.c b/dlls/setupapi/tests/misc.c
index 60960b2..f949997 100644
--- a/dlls/setupapi/tests/misc.c
+++ b/dlls/setupapi/tests/misc.c
@@ -46,6 +46,7 @@ static CHAR CURR_DIR[MAX_PATH];
 static BOOL (WINAPI *pSetupGetFileCompressionInfoExA)(PCSTR, PSTR, DWORD, PDWORD, PDWORD, PDWORD, PUINT);
 static BOOL (WINAPI *pSetupCopyOEMInfA)(PCSTR, PCSTR, DWORD, DWORD, PSTR, DWORD, PDWORD, PSTR *);
 static BOOL (WINAPI *pSetupQueryInfOriginalFileInformationA)(PSP_INF_INFORMATION, UINT, PSP_ALTPLATFORM_INFO, PSP_ORIGINAL_FILE_INFO_A);
+static BOOL (WINAPI *pSetupPromptForDiskW)(HWND, PCWSTR, PCWSTR, PCWSTR, PCWSTR, PCWSTR, DWORD, PWSTR, DWORD, PDWORD);
 
 static void create_inf_file(LPCSTR filename)
 {
@@ -578,6 +579,27 @@ static void test_SetupDecompressOrCopyFile(void)
     DeleteFileA(source);
 }
 
+static void test_SetupPromptForDisk(void)
+{
+    static const WCHAR title[] = {'t','i','t','l','e',0};
+    static const WCHAR disk_name[] = {'d','i','s','k',' ','n','a','m','e',0};
+    static const WCHAR path[] = {'p','a','t','h',0};
+    static const WCHAR file[] = {'f','i','l','e',0};
+    static const WCHAR tag[] = {'t','a','g',0};
+    WCHAR pathbuffer[MAX_PATH];
+    DWORD requiredsize;
+    UINT ret;
+
+    trace("testing SetupPromptForDiskW\n");
+
+    ret=SetupPromptForDiskW(NULL, NULL, NULL, NULL, NULL, NULL, IDF_CHECKFIRST, NULL, 0, NULL);
+    ok(ret == 0, "%d error %d\n",ret,GetLastError());    
+    ret=SetupPromptForDiskW(NULL, title, disk_name, path, file, tag, IDF_OEMDISK, NULL, 0, &requiredsize);
+    ok(ret == 0, "%d\n",ret);    
+    ret=SetupPromptForDiskW(NULL, title, disk_name, path, file, tag, IDF_NOBROWSE, pathbuffer, MAX_PATH, NULL);
+    ok(ret == 0, "%d\n",ret);    
+}
+
 START_TEST(misc)
 {
     HMODULE hsetupapi = GetModuleHandle("setupapi.dll");
@@ -585,6 +607,7 @@ START_TEST(misc)
     pSetupGetFileCompressionInfoExA = (void*)GetProcAddress(hsetupapi, "SetupGetFileCompressionInfoExA");
     pSetupCopyOEMInfA = (void*)GetProcAddress(hsetupapi, "SetupCopyOEMInfA");
     pSetupQueryInfOriginalFileInformationA = (void*)GetProcAddress(hsetupapi, "SetupQueryInfOriginalFileInformationA");
+    pSetupPromptForDiskW = (void*)GetProcAddress(hsetupapi, "SetupPromptForDiskW");
 
     GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
 
@@ -601,4 +624,9 @@ START_TEST(misc)
         skip("SetupGetFileCompressionInfoExA is not available\n");
 
     test_SetupDecompressOrCopyFile();
+
+    if (pSetupPromptForDiskW)
+        test_SetupPromptForDisk();
+    else
+        skip("SetupPromptForDiskW is not available\n"); 
 }
diff --git a/include/setupapi.h b/include/setupapi.h
index b36243a..bb5c982 100644
--- a/include/setupapi.h
+++ b/include/setupapi.h
@@ -1293,13 +1293,13 @@ DECL_WINELIB_SETUPAPI_TYPE_AW(PSP_INF_SIGNER_INFO)
 #define SPDRP_REMOVAL_POLICY_HW_DEFAULT   0x00000020
 #define SPDRP_REMOVAL_POLICY_OVERRIDE     0x00000021
 #define SPDRP_INSTALL_STATE               0x00000022
-#define SPDRP_MAXIMUM_PROPERTY            0x00000023
+#define SPDRP_MAXIMUM_PROPERTY            0x00000023																																																																																													
 
-#define DPROMPT_SUCCESS       0
-#define DPROMPT_CANCEL        1
-#define DPROMPT_SKIPFILE      2
-#define DPROMPT_BUFFERTOSMALL 3
-#define DPROMPT_OUTOFMEMORY   4
+#define DPROMPT_SUCCESS        0
+#define DPROMPT_CANCEL         1
+#define DPROMPT_SKIPFILE       2
+#define DPROMPT_BUFFERTOOSMALL 3
+#define DPROMPT_OUTOFMEMORY    4
 
 #define SETDIRID_NOT_FULL_PATH 0x00000001
 
@@ -1311,6 +1311,10 @@ DECL_WINELIB_SETUPAPI_TYPE_AW(PSP_INF_SIGNER_INFO)
 #define IDF_NOBEEP       0x00000200
 #define IDF_NOFOREGROUND 0x00000400
 #define IDF_WARNIFSKIP   0x00000800
+
+#define IDF_NOREMOVABLEMEDIAPROMPT      0x00001000
+#define IDF_USEDISKNAMEASPROMPT         0x00002000
+#define IDF_OEMDISK                     0x80000000
 
 #define INFINFO_INF_SPEC_IS_HINF        1
 #define INFINFO_INF_NAME_IS_ABSOLUTE    2
-- 
1.5.6.3


More information about the wine-devel mailing list