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.
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.
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.
20 * PURPOSE: Pass INF files to setupapi.dll for execution
21 * PROGRAMMER: Michael Biggins
30 VOID WINAPI
InstallHinfSectionW(HWND hwnd
, HINSTANCE handle
, LPCWSTR cmdline
, INT show
);
31 #define InstallHinfSection InstallHinfSectionW
33 VOID WINAPI
InstallHinfSectionA(HWND hwnd
, HINSTANCE handle
, LPCSTR cmdline
, INT show
);
34 #define InstallHinfSection InstallHinfSectionA
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")
43 _tmain(int argc
, TCHAR
*argv
[])
45 TCHAR infCommand
[MAX_PATH
+ 32];
49 TCHAR FileName
[MAX_PATH
+ 1];
53 ZeroMemory(&ofc
, sizeof(ofc
));
54 ZeroMemory(FileName
, MAX_PATH
+ 1);
55 ofc
.lStructSize
= sizeof(ofc
);
56 ofc
.lpstrFilter
= FILEOPEN_FILTER
;
58 ofc
.lpstrTitle
= FILEOPEN_TITLE
;
59 ofc
.Flags
= OFN_FILEMUSTEXIST
| OFN_LONGNAMES
| OFN_PATHMUSTEXIST
;
60 ofc
.lpstrDefExt
= FILEOPEN_DEFEXT
;
61 ofc
.lpstrFile
= FileName
;
62 ofc
.nMaxFile
= sizeof(FileName
) / sizeof(TCHAR
);
64 rv
= GetOpenFileName(&ofc
);
69 _stprintf(infCommand
, INF_COMMAND
, FileName
);
73 if (_tcslen(argv
[1]) > MAX_PATH
)
75 MessageBox(NULL
, TEXT("Command line too long to be a valid file name"), NULL
, MB_OK
| MB_ICONERROR
);
76 return 2; /* User error */
78 _stprintf(infCommand
, INF_COMMAND
, argv
[1]);
81 InstallHinfSection(NULL
, NULL
, infCommand
, 0);