From ee9baf28d2391a7607468d52d6abed1abeb4dcb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Hentschel?= Date: Sun, 21 Jun 2009 17:05:41 +0200 Subject: [PATCH] appwiz: Add function for installer button. --- dlls/appwiz.cpl/De.rc | 1 + dlls/appwiz.cpl/En.rc | 1 + dlls/appwiz.cpl/Makefile.in | 2 +- dlls/appwiz.cpl/appwiz.c | 50 +++++++++++++++++++++++++++++++++++++ dlls/appwiz.cpl/res.h | 1 + 5 files changed, 54 insertions(+), 1 deletion(-) diff --git a/dlls/appwiz.cpl/De.rc b/dlls/appwiz.cpl/De.rc index b85d43ec1e6..47263f3b06b 100644 --- a/dlls/appwiz.cpl/De.rc +++ b/dlls/appwiz.cpl/De.rc @@ -35,6 +35,7 @@ STRINGTABLE IDS_COLUMN_NAME, "Name" IDS_COLUMN_PUBLISHER, "Herausgeber" IDS_COLUMN_VERSION, "Version" + IDS_INSTALL_FILTER, "Setup-Programme\0*instal*.exe;*setup*.exe;*.msi\0Programme (*.exe)\0*.exe\0Alle Dateien (*.*)\0*.*\0\0" } IDD_MAIN DIALOG 0, 0, 320, 220 diff --git a/dlls/appwiz.cpl/En.rc b/dlls/appwiz.cpl/En.rc index d0b4de3ce6a..3463b2ede1e 100644 --- a/dlls/appwiz.cpl/En.rc +++ b/dlls/appwiz.cpl/En.rc @@ -33,6 +33,7 @@ STRINGTABLE IDS_COLUMN_NAME, "Name" IDS_COLUMN_PUBLISHER, "Publisher" IDS_COLUMN_VERSION, "Version" + IDS_INSTALL_FILTER, "Installation Programs\0*instal*.exe;*setup*.exe;*.msi\0Programs (*.exe)\0*.exe\0All Files (*.*)\0*.*\0\0" } IDD_MAIN DIALOG 0, 0, 320, 220 diff --git a/dlls/appwiz.cpl/Makefile.in b/dlls/appwiz.cpl/Makefile.in index 141715d7447..8fc65f11f5d 100644 --- a/dlls/appwiz.cpl/Makefile.in +++ b/dlls/appwiz.cpl/Makefile.in @@ -3,7 +3,7 @@ TOPOBJDIR = ../.. SRCDIR = @srcdir@ VPATH = @srcdir@ MODULE = appwiz.cpl -IMPORTS = kernel32 comctl32 advapi32 shell32 user32 +IMPORTS = kernel32 comctl32 advapi32 shell32 user32 comdlg32 C_SRCS = \ appwiz.c diff --git a/dlls/appwiz.cpl/appwiz.c b/dlls/appwiz.cpl/appwiz.c index 892c6354a17..daf3e82c49a 100644 --- a/dlls/appwiz.cpl/appwiz.c +++ b/dlls/appwiz.cpl/appwiz.c @@ -41,6 +41,7 @@ #include #include #include +#include #include #include "res.h" @@ -71,6 +72,8 @@ typedef struct APPINFO { static struct APPINFO *AppInfo = NULL; static HINSTANCE hInst; +static const WCHAR openW[] = {'o','p','e','n',0}; + /* names of registry keys */ static const WCHAR BackSlashW[] = { '\\', 0 }; static const WCHAR DisplayNameW[] = {'D','i','s','p','l','a','y','N','a','m','e',0}; @@ -371,6 +374,49 @@ static void UpdateButtons(HWND hWnd) EnableWindow(GetDlgItem(hWnd, IDC_SUPPORT_INFO), sel); } +/****************************************************************************** + * Name : InstallProgram + * Description: Search for potential Installer and execute it. + * Parameters : hWnd - Handle of the dialog box + */ +static void InstallProgram(HWND hWnd) +{ + OPENFILENAMEW ofn; + WCHAR titleW[MAX_STRING_LEN]; + WCHAR FilterBufferW[MAX_STRING_LEN]; + WCHAR FileNameBufferW[MAX_PATH]; + + LoadStringW(hInst, IDS_CPL_TITLE, titleW, sizeof(titleW)/sizeof(WCHAR)); + LoadStringW(hInst, IDS_INSTALL_FILTER, FilterBufferW, sizeof(FilterBufferW)/sizeof(WCHAR)); + + memset(&ofn, 0, sizeof(OPENFILENAMEW)); + ofn.lStructSize = sizeof(OPENFILENAMEW); + ofn.hwndOwner = hWnd; + ofn.hInstance = hInst; + ofn.lpstrFilter = FilterBufferW; + ofn.nFilterIndex = 0; + ofn.lpstrFile = FileNameBufferW; + ofn.nMaxFile = MAX_PATH; + ofn.lpstrFileTitle = NULL; + ofn.nMaxFileTitle = 0; + ofn.lpstrTitle = titleW; + ofn.Flags = OFN_HIDEREADONLY | OFN_ENABLESIZING; + FileNameBufferW[0] = 0; + + if (GetOpenFileNameW(&ofn)) + { + SHELLEXECUTEINFOW sei; + memset(&sei, 0, sizeof(sei)); + sei.cbSize = sizeof(sei); + sei.lpVerb = openW; + sei.nShow = SW_SHOWDEFAULT; + sei.fMask = SEE_MASK_NO_CONSOLE; + sei.lpFile = ofn.lpstrFile; + + ShellExecuteExW(&sei); + } +} + /****************************************************************************** * Name : UninstallProgram * Description: Executes the specified program's installer. @@ -737,6 +783,10 @@ static BOOL CALLBACK MainDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPar case WM_COMMAND: switch (LOWORD(wParam)) { + case IDC_INSTALL: + InstallProgram(hWnd); + break; + case IDC_ADDREMOVE: selitem = SendDlgItemMessageW(hWnd, IDL_PROGRAMS, LVM_GETNEXTITEM, -1, LVNI_FOCUSED|LVNI_SELECTED); diff --git a/dlls/appwiz.cpl/res.h b/dlls/appwiz.cpl/res.h index 34129c4d375..5efcee2feab 100644 --- a/dlls/appwiz.cpl/res.h +++ b/dlls/appwiz.cpl/res.h @@ -53,3 +53,4 @@ #define IDS_COLUMN_NAME 6 #define IDS_COLUMN_PUBLISHER 7 #define IDS_COLUMN_VERSION 8 +#define IDS_INSTALL_FILTER 9