ReactOS 0.4.15-dev-8191-gbc6c731
appwiz.c File Reference
#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include <tchar.h>
Include dependency graph for appwiz.c:

Go to the source code of this file.

Macros

#define SHOW_ALL   1
 
#define APP_ONLY   2
 
#define UPD_ONLY   3
 

Functions

void PrintHelp ()
 
void RunGUIAppWiz ()
 
void CallUninstall (LPTSTR szUninstallString)
 
int ShowAppList (DWORD dwMode, INT iItem)
 
int _tmain (int argc, _TCHAR *argv[])
 

Macro Definition Documentation

◆ APP_ONLY

#define APP_ONLY   2

Definition at line 12 of file appwiz.c.

◆ SHOW_ALL

#define SHOW_ALL   1

Definition at line 11 of file appwiz.c.

◆ UPD_ONLY

#define UPD_ONLY   3

Definition at line 13 of file appwiz.c.

Function Documentation

◆ _tmain()

int _tmain ( int  argc,
_TCHAR argv[] 
)

Definition at line 201 of file appwiz.c.

202{
203 INT iNumber;
204 TCHAR Char[4 + 1];
205
206 SetConsoleTitle(_T("Application Wizard"));
207
208 if (argc < 2)
209 {
210 RunGUIAppWiz();
211 return 0;
212 }
213
214 if (_tcsncmp(argv[1], _T("/?"), 2) == 0)
215 {
216 PrintHelp();
217 return 0;
218 }
219
220 if (_tcsncmp(argv[1], _T("/l"), 2) == 0)
221 {
222 if (argc < 3) goto ShowAll;
223 if (_tcsncmp(argv[2], _T("/all"), 4) == 0)
224 {
225ShowAll:
226 if (ShowAppList(SHOW_ALL, -1) == 0) return 0;
227 scanf(_T("%s"), Char);
228
229 iNumber = atoi(Char);
230
231 if (iNumber == 0) return 0;
232 ShowAppList(SHOW_ALL, iNumber);
233 }
234 else if (_tcsncmp(argv[2], _T("/app"), 4) == 0)
235 {
236 if (ShowAppList(APP_ONLY, -1) == 0) return 0;
237
238 scanf(_T("%s"), Char);
239
240 iNumber = atoi(Char);
241
242 if (iNumber == 0) return 0;
243 ShowAppList(APP_ONLY, iNumber);
244 }
245 else if (_tcsncmp(argv[2], _T("/upd"), 4) == 0)
246 {
247 if (ShowAppList(UPD_ONLY, -1) == 0) return 0;
248
249 scanf(_T("%s"), Char);
250
251 iNumber = atoi(Char);
252
253 if (iNumber == 0) return 0;
254 ShowAppList(UPD_ONLY, iNumber);
255 }
256
257 return 0;
258 }
259
260 return 0;
261}
static int argc
Definition: ServiceArgs.c:12
_Check_return_ _CRTIMP int __cdecl scanf(_In_z_ _Scanf_format_string_ const char *_Format,...)
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
#define _tcsncmp
Definition: tchar.h:1428
#define UPD_ONLY
Definition: appwiz.c:13
void RunGUIAppWiz()
Definition: appwiz.c:34
#define APP_ONLY
Definition: appwiz.c:12
int ShowAppList(DWORD dwMode, INT iItem)
Definition: appwiz.c:91
#define SHOW_ALL
Definition: appwiz.c:11
void PrintHelp()
Definition: appwiz.c:21
#define argv
Definition: mplay32.c:18
int32_t INT
Definition: typedefs.h:58
#define _T(x)
Definition: vfdio.h:22
#define SetConsoleTitle
Definition: wincon.h:783
char TCHAR
Definition: xmlstorage.h:189

◆ CallUninstall()

void CallUninstall ( LPTSTR  szUninstallString)

Definition at line 51 of file appwiz.c.

52{
53 STARTUPINFO si;
55 DWORD dwRet;
56 MSG msg;
57
58 ZeroMemory(&si, sizeof(si));
59 si.cb = sizeof(si);
61
62 if (CreateProcess(NULL, szUninstallString, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
63 {
64 CloseHandle(pi.hThread);
65
66 for (;;)
67 {
69 if (dwRet == WAIT_OBJECT_0 + 1)
70 {
71 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
72 {
75 }
76 }
77 else if (dwRet == WAIT_OBJECT_0 || dwRet == WAIT_FAILED)
78 break;
79 }
80 CloseHandle(pi.hProcess);
81 }
82}
#define msg(x)
Definition: auth_time.c:54
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define INFINITE
Definition: serial.h:102
unsigned long DWORD
Definition: ntddk_ex.h:95
static refpint_t pi[]
Definition: server.c:96
DWORD cb
Definition: winbase.h:831
WORD wShowWindow
Definition: winbase.h:843
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
#define CreateProcess
Definition: winbase.h:3758
#define ZeroMemory
Definition: winbase.h:1712
#define WAIT_OBJECT_0
Definition: winbase.h:406
#define WAIT_FAILED
Definition: winbase.h:413
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define QS_ALLEVENTS
Definition: winuser.h:902
DWORD WINAPI MsgWaitForMultipleObjects(_In_ DWORD nCount, _In_reads_opt_(nCount) CONST HANDLE *pHandles, _In_ BOOL fWaitAll, _In_ DWORD dwMilliseconds, _In_ DWORD dwWakeMask)
#define PM_REMOVE
Definition: winuser.h:1196
#define PeekMessage
Definition: winuser.h:5839
#define SW_SHOW
Definition: winuser.h:775
#define DispatchMessage
Definition: winuser.h:5774

Referenced by ShowAppList().

◆ PrintHelp()

void PrintHelp ( )

Definition at line 21 of file appwiz.c.

22{
23 printf(_T("Add or Remove Programs\n\
24APPWIZ [/? /l] [/all /app /upd]\n\
25 /?\t Help\n\
26 /l\t Show list\n\
27 /all\t Show programs and updates\n\
28 /app\t Show programs only\n\
29 /upd\t Show updates only\n"));
30 _getch();
31}
#define printf
Definition: freeldr.h:97
int _getch()
Definition: getch.c:16

Referenced by _tmain(), AssocQ(), and wmain().

◆ RunGUIAppWiz()

void RunGUIAppWiz ( )

Definition at line 34 of file appwiz.c.

35{
36 SHELLEXECUTEINFO shInputDll;
37
38 memset(&shInputDll, 0x0, sizeof(SHELLEXECUTEINFO));
39 shInputDll.cbSize = sizeof(shInputDll);
40 shInputDll.hwnd = NULL;
41 shInputDll.lpVerb = _T("open");
42 shInputDll.lpFile = _T("RunDll32.exe");
43 shInputDll.lpParameters = _T("shell32.dll,Control_RunDLL appwiz.cpl");
44
45 if (ShellExecuteEx(&shInputDll) == 0)
46 {
47 MessageBox(NULL, _T("Can not start appwiz.cpl"), NULL, MB_OK | MB_ICONERROR);
48 }
49}
#define memset(x, y, z)
Definition: compat.h:39
#define ShellExecuteEx
Definition: shellapi.h:694
LPCSTR lpParameters
Definition: shellapi.h:316
#define MB_ICONERROR
Definition: winuser.h:787
#define MB_OK
Definition: winuser.h:790
#define MessageBox
Definition: winuser.h:5831

Referenced by _tmain().

◆ ShowAppList()

int ShowAppList ( DWORD  dwMode,
INT  iItem 
)

Definition at line 91 of file appwiz.c.

92{
93 HKEY hKey, hSubKey;
94 DWORD dwSize, dwType, dwValue;
96 TCHAR szParentKeyName[MAX_PATH];
97 TCHAR szDisplayName[MAX_PATH];
98 TCHAR szOutBuf[MAX_PATH];
99 FILETIME FileTime;
100 BOOL bIsUpdate = FALSE;
101 BOOL bIsSystemComponent = FALSE;
102 INT iIndex = 0, iColor = 0, iCount = 1;
103 HANDLE hOutput;
104
106 _T("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"),
107 &hKey) != ERROR_SUCCESS)
108 {
109 printf(_T("ERROR: Can not open Uninstall key. Press any key for continue...\n"));
110 _getch();
111 return 0;
112 }
113
116
118 while (RegEnumKeyEx(hKey, iIndex, szName, &dwSize, NULL, NULL, NULL, &FileTime) == ERROR_SUCCESS)
119 {
120 if (RegOpenKey(hKey, szName, &hSubKey) == ERROR_SUCCESS)
121 {
122 dwType = REG_DWORD;
123 dwSize = sizeof(DWORD);
124
125 if (RegQueryValueEx(hSubKey, _T("SystemComponent"),
126 NULL, &dwType,
127 (LPBYTE)&dwValue, &dwSize) == ERROR_SUCCESS)
128 {
129 bIsSystemComponent = (dwValue == 0x1);
130 }
131 else
132 {
133 bIsSystemComponent = FALSE;
134 }
135
136 dwType = REG_SZ;
138
139 bIsUpdate = (RegQueryValueEx(hSubKey, _T("ParentKeyName"),
140 NULL, &dwType,
141 (LPBYTE) szParentKeyName,
142 &dwSize) == ERROR_SUCCESS);
144 if (RegQueryValueEx(hSubKey, _T("DisplayName"),
145 NULL, &dwType,
146 (LPBYTE) szDisplayName,
148 {
149 if (!bIsSystemComponent)
150 {
151 if ((dwMode == SHOW_ALL) || ((dwMode == APP_ONLY) && (!bIsUpdate)) || ((dwMode == UPD_ONLY) && (bIsUpdate)))
152 {
153 if (iItem == -1)
154 {
155 wsprintf(szOutBuf, _T(" %d \t %s\n"), iCount, szDisplayName);
156 CharToOem(szOutBuf, szOutBuf);
157 printf("%s", szOutBuf);
158 }
159 else
160 {
161 dwType = REG_SZ;
163
164 if ((RegQueryValueEx(hSubKey, _T("UninstallString"), NULL, &dwType,
165 (LPBYTE) szOutBuf, &dwSize) == ERROR_SUCCESS) && (iItem == iCount))
166 {
167 CallUninstall(szOutBuf);
168 }
169 }
170 iCount++;
171 iColor++;
172 }
173 }
174 }
175 }
176
177 if (iColor <= 5)
178 {
180 }
181 else
182 {
184 if (iColor >= 10) iColor = 0;
185 }
186
188 iIndex++;
189 }
190
191 RegCloseKey(hSubKey);
193
195 printf("\n\nPlease enter application/update number and press ENTER for uninstall\nor press any key for Exit...\n");
196
197 return 1;
198}
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:203
BOOL WINAPI SetConsoleTextAttribute(IN HANDLE hConsoleOutput, IN WORD wAttributes)
Definition: console.c:672
#define FOREGROUND_INTENSITY
Definition: blue.h:64
#define FOREGROUND_GREEN
Definition: blue.h:62
#define FOREGROUND_RED
Definition: blue.h:63
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
#define MAX_PATH
Definition: compat.h:34
unsigned int BOOL
Definition: ntddk_ex.h:94
FxAutoRegKey hKey
#define REG_SZ
Definition: layer.c:22
void CallUninstall(LPTSTR szUninstallString)
Definition: appwiz.c:51
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define DWORD
Definition: nt_native.h:44
static const WCHAR szName[]
Definition: powrprof.c:45
#define REG_DWORD
Definition: sdbapi.c:596
unsigned char * LPBYTE
Definition: typedefs.h:53
#define STD_OUTPUT_HANDLE
Definition: winbase.h:268
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define RegQueryValueEx
Definition: winreg.h:524
#define RegOpenKey
Definition: winreg.h:519
#define RegEnumKeyEx
Definition: winreg.h:510
#define wsprintf
Definition: winuser.h:5874
#define CharToOem
Definition: winuser.h:5752
_In_ ULONG iColor
Definition: xlateobj.h:17

Referenced by _tmain().