ReactOS 0.4.15-dev-7958-gcd0bb1a
infinst.c
Go to the documentation of this file.
1/*
2 * ReactOS INF Helper
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 *
18 * PROJECT: INF Helper
19 * FILE: infinst.c
20 * PURPOSE: Pass INF files to setupapi.dll for execution
21 * PROGRAMMER: Michael Biggins
22 * UPDATE HISTORY:
23 * Created 19/09/2004
24 */
25#include <windows.h>
26#include <tchar.h>
27#include <stdio.h>
28
29#ifdef UNICODE
31#define InstallHinfSection InstallHinfSectionW
32#else
34#define InstallHinfSection InstallHinfSectionA
35#endif
36
37#define FILEOPEN_FILTER TEXT("Inf Files (*.inf)\0*.inf\0All Files (*.*)\0*.*\0\0")
38#define FILEOPEN_TITLE TEXT("INF file to process")
39#define FILEOPEN_DEFEXT TEXT(".inf")
40#define INF_COMMAND TEXT("DefaultInstall 128 %s")
41
42int
44{
45 TCHAR infCommand[MAX_PATH + 32];
46
47 if (argc <= 1)
48 {
50 OPENFILENAME ofc;
51 int rv;
52
53 ZeroMemory(&ofc, sizeof(ofc));
55 ofc.lStructSize = sizeof(ofc);
57 ofc.nFilterIndex = 1;
61 ofc.lpstrFile = FileName;
62 ofc.nMaxFile = sizeof(FileName) / sizeof(TCHAR);
63
64 rv = GetOpenFileName(&ofc);
65
66 if (rv == 0)
67 return 1;
68
69 _stprintf(infCommand, INF_COMMAND, FileName);
70 }
71 else
72 {
73 if (_tcslen(argv[1]) > MAX_PATH)
74 {
75 MessageBox(NULL, TEXT("Command line too long to be a valid file name"), NULL, MB_OK | MB_ICONERROR);
76 return 2; /* User error */
77 }
78 _stprintf(infCommand, INF_COMMAND, argv[1]);
79 }
80
81 InstallHinfSection(NULL, NULL, infCommand, 0);
82
83 return 0;
84}
static int argc
Definition: ServiceArgs.c:12
#define OFN_EXPLORER
Definition: commdlg.h:104
#define OFN_LONGNAMES
Definition: commdlg.h:108
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
#define GetOpenFileName
Definition: commdlg.h:665
#define NULL
Definition: types.h:112
#define MAX_PATH
Definition: compat.h:34
void WINAPI InstallHinfSectionW(HWND hwnd, HINSTANCE handle, LPCWSTR cmdline, INT show)
Definition: install.c:1465
struct _FileName FileName
Definition: fatprocs.h:896
#define _tmain
Definition: tchar.h:497
#define INF_COMMAND
Definition: infinst.c:40
#define FILEOPEN_DEFEXT
Definition: infinst.c:39
#define InstallHinfSection
Definition: infinst.c:34
#define FILEOPEN_TITLE
Definition: infinst.c:38
#define FILEOPEN_FILTER
Definition: infinst.c:37
VOID WINAPI InstallHinfSectionA(HWND hwnd, HINSTANCE handle, LPCSTR cmdline, INT show)
Definition: install.c:1598
#define TEXT(s)
Definition: k32.h:26
#define _stprintf
Definition: utility.h:124
#define argv
Definition: mplay32.c:18
TCHAR * cmdline
Definition: stretchblt.cpp:32
LPCSTR lpstrDefExt
Definition: commdlg.h:345
DWORD nFilterIndex
Definition: commdlg.h:335
LPCSTR lpstrTitle
Definition: commdlg.h:341
LPSTR lpstrFile
Definition: commdlg.h:336
DWORD Flags
Definition: commdlg.h:342
DWORD lStructSize
Definition: commdlg.h:329
LPCSTR lpstrFilter
Definition: commdlg.h:332
DWORD nMaxFile
Definition: commdlg.h:337
int32_t INT
Definition: typedefs.h:58
#define ZeroMemory
Definition: winbase.h:1712
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define WINAPI
Definition: msvc.h:6
#define MB_ICONERROR
Definition: winuser.h:787
#define MB_OK
Definition: winuser.h:790
#define MessageBox
Definition: winuser.h:5822
char TCHAR
Definition: xmlstorage.h:189
const char * LPCSTR
Definition: xmlstorage.h:183
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define _tcslen
Definition: xmlstorage.h:198