ReactOS  0.4.14-dev-999-g61c8d34
infinst.c File Reference
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
Include dependency graph for infinst.c:

Go to the source code of this file.

Macros

#define InstallHinfSection   InstallHinfSectionA
 
#define FILEOPEN_FILTER   TEXT("Inf Files (*.inf)\0*.inf\0All Files (*.*)\0*.*\0\0")
 
#define FILEOPEN_TITLE   TEXT("INF file to process")
 
#define FILEOPEN_DEFEXT   TEXT(".inf")
 
#define INF_COMMAND   TEXT("DefaultInstall 128 %s")
 

Functions

VOID WINAPI InstallHinfSectionA (HWND hwnd, HINSTANCE handle, LPCSTR cmdline, INT show)
 
int _tmain (int argc, TCHAR *argv[])
 

Macro Definition Documentation

◆ FILEOPEN_DEFEXT

#define FILEOPEN_DEFEXT   TEXT(".inf")

Definition at line 39 of file infinst.c.

◆ FILEOPEN_FILTER

#define FILEOPEN_FILTER   TEXT("Inf Files (*.inf)\0*.inf\0All Files (*.*)\0*.*\0\0")

Definition at line 37 of file infinst.c.

◆ FILEOPEN_TITLE

#define FILEOPEN_TITLE   TEXT("INF file to process")

Definition at line 38 of file infinst.c.

◆ INF_COMMAND

#define INF_COMMAND   TEXT("DefaultInstall 128 %s")

Definition at line 40 of file infinst.c.

◆ InstallHinfSection

#define InstallHinfSection   InstallHinfSectionA

Definition at line 34 of file infinst.c.

Function Documentation

◆ _tmain()

int _tmain ( int  argc,
TCHAR argv[] 
)

Definition at line 43 of file infinst.c.

44 {
45  TCHAR infCommand[MAX_PATH + 32];
46 
47  if (argc <= 1)
48  {
49  TCHAR FileName[MAX_PATH + 1];
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 }
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
static int argc
Definition: ServiceArgs.c:12
#define OFN_LONGNAMES
Definition: commdlg.h:108
#define ZeroMemory
Definition: winbase.h:1642
LPCSTR lpstrDefExt
Definition: commdlg.h:345
#define argv
Definition: mplay32.c:18
#define GetOpenFileName
Definition: commdlg.h:665
DWORD nMaxFile
Definition: commdlg.h:337
#define FILEOPEN_DEFEXT
Definition: infinst.c:39
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
smooth NULL
Definition: ftsmooth.c:416
#define FILEOPEN_TITLE
Definition: infinst.c:38
#define InstallHinfSection
Definition: infinst.c:34
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
char TCHAR
Definition: xmlstorage.h:189
#define MAX_PATH
Definition: compat.h:26
DWORD lStructSize
Definition: commdlg.h:329
#define INF_COMMAND
Definition: infinst.c:40
#define MB_ICONERROR
Definition: winuser.h:781
#define MessageBox
Definition: winuser.h:5797
#define _stprintf
Definition: utility.h:124
struct _FileName FileName
Definition: fatprocs.h:884
#define TEXT(s)
Definition: k32.h:26
LPSTR lpstrFile
Definition: commdlg.h:336
#define FILEOPEN_FILTER
Definition: infinst.c:37
LPCSTR lpstrFilter
Definition: commdlg.h:332
#define MB_OK
Definition: winuser.h:784
LPCSTR lpstrTitle
Definition: commdlg.h:341
DWORD nFilterIndex
Definition: commdlg.h:335
DWORD Flags
Definition: commdlg.h:342

◆ InstallHinfSectionA()

VOID WINAPI InstallHinfSectionA ( HWND  hwnd,
HINSTANCE  handle,
LPCSTR  cmdline,
INT  show 
)

Definition at line 1598 of file install.c.

1599 {
1600  UNICODE_STRING cmdlineW;
1601 
1602  if (RtlCreateUnicodeStringFromAsciiz( &cmdlineW, cmdline ))
1603  {
1604  InstallHinfSectionW( hwnd, handle, cmdlineW.Buffer, show );
1605  RtlFreeUnicodeString( &cmdlineW );
1606  }
1607 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
TCHAR * cmdline
Definition: stretchblt.cpp:32
void WINAPI InstallHinfSectionW(HWND hwnd, HINSTANCE handle, LPCWSTR cmdline, INT show)
Definition: install.c:1465
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)