appwiz: Add function for installer button.
This commit is contained in:
parent
d9972cb4b4
commit
ee9baf28d2
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include <winreg.h>
|
||||
#include <shellapi.h>
|
||||
#include <commctrl.h>
|
||||
#include <commdlg.h>
|
||||
#include <cpl.h>
|
||||
|
||||
#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);
|
||||
|
|
|
@ -53,3 +53,4 @@
|
|||
#define IDS_COLUMN_NAME 6
|
||||
#define IDS_COLUMN_PUBLISHER 7
|
||||
#define IDS_COLUMN_VERSION 8
|
||||
#define IDS_INSTALL_FILTER 9
|
||||
|
|
Loading…
Reference in New Issue