-
Notifications
You must be signed in to change notification settings - Fork 2
/
GraphicalUserInterface.h
518 lines (454 loc) · 16.4 KB
/
GraphicalUserInterface.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
#pragma once
#include "stdafx.h"
#include "Resources.h"
#include "IPFirewall.h"
#include "XMLWriter.h"
#include "XMLReader.h"
#include "RuleHandling.h"
namespace GraphicalUserInterface
{
HWND HwndMainWindow = NULL;
IPFirewall firewall;
bool RegisterWindowClass(HINSTANCE);
bool CreateMainWindow(HINSTANCE, int);
void InitializeWindowComponents(HWND);
LRESULT CALLBACK MainWindowProcess(HWND, UINT, WPARAM, LPARAM);
string GetText(HWND);
LRESULT CustomDrawListview(NMLVCUSTOMDRAW*, LPARAM, HWND);
void GiveButtonColor(LPNMCUSTOMDRAW, COLORREF, COLORREF);
HBRUSH CreateGradientBrush(COLORREF, COLORREF, LPNMCUSTOMDRAW);
void AddRulesToListbox(HWND);
}
/* Creating windows by registering and call the CreateWindow function. */
bool GraphicalUserInterface::RegisterWindowClass(HINSTANCE hInstance)
{
WNDCLASSEX wc;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = GraphicalUserInterface::MainWindowProcess;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadIcon(NULL, IDC_HAND);
wc.hbrBackground = CreateSolidBrush(RGB(0, 0, 0));
wc.lpszMenuName = WindowTitleName;
wc.lpszClassName = WindowClassName;
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if (!RegisterClassEx(&wc))
{
MessageBoxA(NULL, "Window registration failed!", "IF: Error", MB_OK | MB_ICONERROR);
return false;
}
return true;
}
bool GraphicalUserInterface::CreateMainWindow(HINSTANCE hInstance, int nCmdShow)
{
HWND hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, WindowClassName, WindowTitleName,
WS_OVERLAPPEDWINDOW | WS_BORDER, 100, 50, 800, 650,
NULL, NULL, hInstance, NULL);
if (hwnd == NULL)
{
MessageBoxA(NULL, "Failed to create a window!", "IPS: Error", MB_OK | MB_ICONERROR);
return false;
}
HwndMainWindow = hwnd;
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
return true;
}
/* Creates the interactive controls in the main window. */
void GraphicalUserInterface::InitializeWindowComponents(HWND hwndParent)
{
// Global variables to use.
HINSTANCE hInstance = (HINSTANCE)GetWindowLong(hwndParent, GWL_HINSTANCE);
HFONT defaultFont = CreateFontA(20, 0, FW_DONTCARE, FALSE, FW_MEDIUM, FALSE, FALSE, FALSE,
ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH | FF_SWISS, "Consolas");
HFONT ListviewFONT = CreateFontA(22, 0, FW_DONTCARE, FALSE, FW_MEDIUM, FALSE, FALSE, FALSE,
ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH | FF_SWISS, "Consolas");
/* Creating controls for window. */
HWND label1 = CreateWindowEx(WS_EX_TRANSPARENT, "STATIC", "Status: ",
WS_CHILD | WS_SYSMENU | WS_VISIBLE | SS_LEFT,
50, 30, 100, 30,
hwndParent, (HMENU)0, hInstance, 0);
SendMessage(label1, WM_SETFONT, (WPARAM)defaultFont, (LPARAM)TRUE);
HWND label2 = CreateWindowEx(WS_EX_TRANSPARENT, "STATIC", "Firewall offline",
WS_CHILD | WS_SYSMENU | WS_VISIBLE | SS_LEFT,
120, 30, 300, 30,
hwndParent, (HMENU)LABEL_STATUS2, hInstance, 0);
SendMessage(label2, WM_SETFONT, (WPARAM)defaultFont, (LPARAM)TRUE);
HWND label3 = CreateWindowEx(WS_EX_TRANSPARENT, "STATIC", "Blocked IP addresses:",
WS_CHILD | WS_VISIBLE | WS_SYSMENU | SS_LEFT | WS_BORDER,
30, 80, 450, 30,
hwndParent, (HMENU)0, hInstance, 0);
SendMessage(label3, WM_SETFONT, (WPARAM)defaultFont, (LPARAM)TRUE);
HWND listview = CreateWindow("listbox", NULL,
LBS_STANDARD | LBS_SORT | WS_TABSTOP | WS_BORDER | WS_CHILD | WS_VISIBLE,
30, 140, 500, 400,
hwndParent, (HMENU)LISTVIEW_IP, hInstance, 0);
SendMessage(listview, WM_SETFONT, (WPARAM)ListviewFONT, (LPARAM)TRUE);
SendMessage(listview, LVM_SETBKCOLOR, (WPARAM)NULL, (LPARAM)RGB(0, 0, 0));
HWND label4 = CreateWindowEx(WS_EX_TRANSPARENT, "STATIC", "Rule to add:",
WS_CHILD | WS_VISIBLE | WS_SYSMENU | SS_LEFT,
550, 150, 200, 30,
hwndParent, (HMENU)0, hInstance, 0);
SendMessage(label4, WM_SETFONT, (WPARAM)defaultFont, (LPARAM)TRUE);
HWND ipinput = CreateWindowEx(WS_EX_TRANSPARENT, WC_IPADDRESS, "",
WS_CHILD | WS_VISIBLE | WS_SYSMENU | SS_LEFT,
550, 190, 200, 24,
hwndParent, (HMENU)INPUT_IPADDR, hInstance, 0);
SendMessage(ipinput, WM_SETFONT, (WPARAM)ListviewFONT, (LPARAM)TRUE);
HWND button = CreateWindow("BUTTON", "Add IP rule",
WS_CHILD | WS_VISIBLE | WS_SYSMENU | BS_PUSHBUTTON,
550, 230, 200, 30, hwndParent,
(HMENU)BUTTON_ADDRULES, hInstance, 0);
SendMessage(button, WM_SETFONT, (WPARAM)defaultFont, (LPARAM)TRUE);
HWND button2 = CreateWindow("BUTTON", "Start Firewall",
WS_CHILD | WS_VISIBLE | WS_SYSMENU | BS_PUSHBUTTON,
550, 50, 200, 30, hwndParent,
(HMENU)BUTTON_FWSWITCH, hInstance, 0);
SendMessage(button2, WM_SETFONT, (WPARAM)defaultFont, (LPARAM)TRUE);
HWND label5 = CreateWindowEx(WS_EX_TRANSPARENT, "STATIC", "Rule to delete:",
WS_CHILD | WS_VISIBLE | WS_SYSMENU | SS_LEFT,
550, 300, 200, 30,
hwndParent, (HMENU)0, hInstance, 0);
SendMessage(label5, WM_SETFONT, (WPARAM)defaultFont, (LPARAM)TRUE);
HWND label_selected = CreateWindowEx(WS_EX_TRANSPARENT, "STATIC", "NONE_SELECTED",
WS_CHILD | WS_VISIBLE | WS_SYSMENU | SS_LEFT,
550, 340, 200, 30,
hwndParent, (HMENU)LABEL_SELECTEDIP, hInstance, 0);
SendMessage(label_selected, WM_SETFONT, (WPARAM)ListviewFONT, (LPARAM)TRUE);
HWND button3 = CreateWindow("BUTTON", "Delete IP rule",
WS_CHILD | WS_VISIBLE | WS_SYSMENU | SS_LEFT,
550, 380, 200, 30,
hwndParent, (HMENU)BUTTON_DELETERULE, hInstance, 0);
SendMessage(button3, WM_SETFONT, (WPARAM)defaultFont, (LPARAM)TRUE);
HWND button4 = CreateWindow("BUTTON", "Copyrights software",
WS_CHILD | WS_VISIBLE | WS_SYSMENU | SS_LEFT,
550, 550, 200, 30,
hwndParent, (HMENU)BUTTON_COPYRIGHTS, hInstance, 0);
SendMessage(button4, WM_SETFONT, (WPARAM)defaultFont, (LPARAM)TRUE);
}
/* The message loop that runs forever. */
LRESULT CALLBACK GraphicalUserInterface::MainWindowProcess(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
HINSTANCE hInstance = (HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE);
switch (msg)
{
case WM_CREATE:
{
InitializeWindowComponents(hwnd);
break;
}
case WM_NCCREATE:
{
AddRulesToListbox(hwnd);
break;
}
case WM_COMMAND:
{
if (LOWORD(wParam) == BUTTON_ADDRULES && HIWORD(wParam) == BN_CLICKED)
{
string env = getenv("ProgramFiles");
string path = env + "\\IP Firewall\\Profile_" + firewall.WIFI_SSID + ".config";
RuleHandler handler(path);
if (!handler.IsReady())
{
MessageBox(0, "Failed to add IP, RuleHandler not ready!", "IF: Warning", MB_OK | MB_ICONERROR);
break;
}
string IP = GetText(GetDlgItem(hwnd, INPUT_IPADDR));
if (handler.AddRule(IP) == true)
{
SetWindowText(GetDlgItem(hwnd, INPUT_IPADDR), "");
MessageBox(0, "IP succesfully added to list!", "IF: Warning", MB_OK | MB_ICONWARNING);
}
AddRulesToListbox(hwnd);
break;
}
if (LOWORD(wParam) == BUTTON_DELETERULE && HIWORD(wParam) == BN_CLICKED)
{
string env = getenv("ProgramFiles");
string path = env + "\\IP Firewall\\Profile_" + firewall.WIFI_SSID + ".config";
RuleHandler handler(path);
if (!handler.IsReady())
{
MessageBox(0, "Failed to delete rule, RuleHandler not ready!", "IF: Error", MB_OK | MB_ICONERROR);
break;
}
string IP = GetText(GetDlgItem(hwnd, LABEL_SELECTEDIP));
if (handler.DeleteRule(IP) == false)
{
MessageBox(0, "Failed to delete the selected IP address!", "IF: Warning", MB_OK | MB_ICONWARNING);
}
else
{
SetWindowText(GetDlgItem(hwnd, LABEL_SELECTEDIP), " ");
SetWindowText(GetDlgItem(hwnd, LABEL_SELECTEDIP), "NONE_SELECTED");
MessageBox(0, "Succesfully deleted the selected IP address!", "IF: Warning", MB_OK | MB_ICONINFORMATION);
}
AddRulesToListbox(hwnd);
break;
}
if (LOWORD(wParam) == BUTTON_FWSWITCH && HIWORD(wParam) == BN_CLICKED)
{
if (firewall.IsFirewallRunning == false)
{
if (firewall.StartFirewall(GetDlgItem(hwnd, LISTVIEW_IP)) == false)
MessageBox(0, "Failed to start the firewall!", "IF: Error", MB_OK | MB_ICONERROR);
else
{
SetWindowText(GetDlgItem(hwnd, BUTTON_FWSWITCH), "Stop Firewall");
SetWindowText(GetDlgItem(hwnd, LABEL_STATUS2), "Firewall online ");
}
}
else
{
if (firewall.StopFirewall() == false)
MessageBox(0, "Failed to stop the firewall!", "IF: Error", MB_OK | MB_ICONERROR);
else
{
SetWindowText(GetDlgItem(hwnd, BUTTON_FWSWITCH), "Start Firewall");
SetWindowText(GetDlgItem(hwnd, LABEL_STATUS2), "Firewall offline ");
MessageBox(0, "IP Firewall stopped!\n( Not recommended! )", "IF: Info", MB_OK | MB_ICONINFORMATION);
}
}
break;
}
if (LOWORD(wParam) == BUTTON_COPYRIGHTS && HIWORD(wParam) == BN_CLICKED)
{
MessageBox(hwnd, "Project name:\t\t\tIP Firewall\n"
"Author:\t\t\t\tTrisna Quebe\n"
"Creation date:\t\t\t7-10-2019\n\n"
"Copyrights (c) 2019-2020 Trisna Quebe all rights served.", "IF: Copyrights", MB_OK | MB_ICONWARNING);
break;
}
if (LOWORD(wParam) == LISTVIEW_IP && HIWORD(wParam) == LBN_SELCHANGE)
{
int ItemPosition = (int)SendMessage(GetDlgItem(hwnd, LISTVIEW_IP), LB_GETCURSEL, 0, 0);
int ItemLength = (int)SendMessage(GetDlgItem(hwnd, LISTVIEW_IP), LB_GETTEXTLEN, ItemPosition, 0);
char *buffer = new char[ItemLength];
SendMessage(GetDlgItem(hwnd, LISTVIEW_IP), LB_GETTEXT, (WPARAM)ItemPosition, (LPARAM)buffer);
string str = buffer;
SetWindowText(GetDlgItem(hwnd, LABEL_SELECTEDIP), " ");
SetWindowText(GetDlgItem(hwnd, LABEL_SELECTEDIP), str.c_str());
break;
}
break;
}
case WM_NOTIFY:
{
NMHDR* Item = (NMHDR*)lParam;
if (Item->idFrom == LISTVIEW_IP && Item->code == NM_CUSTOMDRAW)
{
return CustomDrawListview((NMLVCUSTOMDRAW*)Item, lParam, GetDlgItem(hwnd, LISTVIEW_IP));
}
if (Item->idFrom == BUTTON_ADDRULES)
{
MessageBoxA(NULL, "TEST", "TEST", MB_OK);
LPNMCUSTOMDRAW BTN = (LPNMCUSTOMDRAW)Item;
GiveButtonColor(BTN, RGB(38, 77, 115), RGB(51, 102, 153));
return CDRF_DODEFAULT;
}
if (Item->idFrom == BUTTON_FWSWITCH)
{
MessageBoxA(NULL, "TEST", "TEST", MB_OK);
LPNMCUSTOMDRAW BTN = (LPNMCUSTOMDRAW)Item;
GiveButtonColor(BTN, RGB(204, 0, 0), RGB(230, 57, 0));
return CDRF_DODEFAULT;
}
return CDRF_DODEFAULT;
}
case WM_CTLCOLORBTN:
{
return (LRESULT)GetSysColorBrush(COLOR_WINDOW + 1);
}
case WM_CTLCOLORSTATIC:
{
DWORD ID = GetDlgCtrlID((HWND)lParam);
if (ID == LABEL_STATUS2)
{
string str = GetText(GetDlgItem(hwnd, LABEL_STATUS2));
if (str == "Firewall offline" || str.find("Error") != string::npos || str.find("offline") != string::npos)
{
HDC hdc = reinterpret_cast<HDC>(wParam);
SetTextColor(hdc, RGB(255, 0, 0));
SetBkColor(hdc, TRANSPARENT);
return (LONG)GetStockObject(NULL_BRUSH);
}
else if (str == "Firewall online" || str.find("online") != string::npos)
{
HDC hdc = reinterpret_cast<HDC>(wParam);
SetTextColor(hdc, RGB(47, 212, 69));
SetBkColor(hdc, TRANSPARENT);
return (LONG)GetStockObject(NULL_BRUSH);
}
else
{
HDC hdc = reinterpret_cast<HDC>(wParam);
SetTextColor(hdc, RGB(221, 226, 106));
SetBkColor(hdc, TRANSPARENT);
return (LONG)GetStockObject(NULL_BRUSH);
}
}
else if (ID == LABEL_SELECTEDIP)
{
string str = GetText(GetDlgItem(hwnd, LABEL_SELECTEDIP));
if (str == "NONE_SELECTED")
{
HDC hdc = reinterpret_cast<HDC>(wParam);
SetTextColor(hdc, RGB(221, 226, 106));
SetBkColor(hdc, TRANSPARENT);
return (LONG)GetStockObject(NULL_BRUSH);
}
else
{
HDC hdc = reinterpret_cast<HDC>(wParam);
SetTextColor(hdc, RGB(255, 0, 0));
SetBkColor(hdc, TRANSPARENT);
return (LONG)GetStockObject(NULL_BRUSH);
}
}
else
{
HDC hdc = reinterpret_cast<HDC>(wParam);
SetTextColor(hdc, RGB(255, 255, 255));
SetBkColor(hdc, RGB(0, 0, 0));
return (LONG)GetStockObject(NULL_BRUSH);
}
break;
}
case WM_CLOSE:
{
DestroyWindow(hwnd);
break;
}
case WM_GETMINMAXINFO:
{
LPMINMAXINFO lpMMI = (LPMINMAXINFO)lParam;
lpMMI->ptMinTrackSize.x = 800;
lpMMI->ptMinTrackSize.y = 650;
lpMMI->ptMaxTrackSize.x = 800;
lpMMI->ptMaxTrackSize.y = 650;
break;
}
case WM_DESTROY:
{
PostQuitMessage(0);
break;
}
default:
break;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
/* Gets text from any control. */
string GraphicalUserInterface::GetText(HWND hwndControl)
{
char buffer[MAX_PATH];
GetWindowText(hwndControl, buffer, MAX_PATH);
return (string)buffer;
}
/* Custom draws the listview we're using in the window. */
LRESULT GraphicalUserInterface::CustomDrawListview(NMLVCUSTOMDRAW* pcd, LPARAM lParam, HWND Listview)
{
LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)lParam;
TCHAR buffer[16];
LVITEM item;
WCHAR ItemText[64];
switch (pcd->nmcd.dwDrawStage)
{
case CDDS_PREPAINT:
{
/* Tell the control we are interested in per-item notifications.*/
return CDRF_DODEFAULT | CDRF_NOTIFYITEMDRAW;
}
case (CDDS_ITEM | CDDS_PREPAINT):
{
lplvcd->clrText = RGB(255, 255, 255);
lplvcd->clrTextBk = RGB(0, 0, 0);
return CDRF_DODEFAULT;
}
}
return CDRF_DODEFAULT;
}
/* Give the buttons in window a hover color and a default color. */
void GraphicalUserInterface::GiveButtonColor(LPNMCUSTOMDRAW BTN, COLORREF HoverColor, COLORREF defaultColor)
{
if (BTN->uItemState & CDIS_HOT)
{
// Select our hot BRUSH color
HBRUSH hotBRUSH = CreateGradientBrush(HoverColor, HoverColor, BTN);
HPEN pen = CreatePen(PS_INSIDEFRAME, 0, RGB(0, 0, 0));
HGDIOBJ old_pen = SelectObject(BTN->hdc, pen);
HGDIOBJ old_brush = SelectObject(BTN->hdc, hotBRUSH);
RoundRect(BTN->hdc, BTN->rc.left, BTN->rc.top, BTN->rc.right, BTN->rc.bottom, 5, 5);
SelectObject(BTN->hdc, old_pen);
SelectObject(BTN->hdc, old_brush);
DeleteObject(pen);
}
else
{
// Select our default BRUSH color
HBRUSH defaultBRUSH = CreateGradientBrush(defaultColor, defaultColor, BTN);
HPEN pen = CreatePen(PS_INSIDEFRAME, 0, RGB(0, 0, 0));
HGDIOBJ old_pen = SelectObject(BTN->hdc, pen);
HGDIOBJ old_brush = SelectObject(BTN->hdc, defaultBRUSH);
RoundRect(BTN->hdc, BTN->rc.left, BTN->rc.top, BTN->rc.right, BTN->rc.bottom, 5, 5);
SelectObject(BTN->hdc, old_pen);
SelectObject(BTN->hdc, old_brush);
DeleteObject(pen);
}
}
HBRUSH GraphicalUserInterface::CreateGradientBrush(COLORREF top, COLORREF bottom, LPNMCUSTOMDRAW item)
{
HBRUSH Brush = NULL;
HDC hdcmem = CreateCompatibleDC(item->hdc);
HBITMAP hbitmap = CreateCompatibleBitmap(item->hdc, item->rc.right - item->rc.left, item->rc.bottom - item->rc.top);
SelectObject(hdcmem, hbitmap);
int r1 = GetRValue(top), r2 = GetRValue(bottom), g1 = GetGValue(top), g2 = GetGValue(bottom), b1 = GetBValue(top), b2 = GetBValue(bottom);
for (int i = 0; i < item->rc.bottom - item->rc.top; i++)
{
RECT temp;
int r, g, b;
r = int(r1 + double(i * (r2 - r1) / item->rc.bottom - item->rc.top));
g = int(g1 + double(i * (g2 - g1) / item->rc.bottom - item->rc.top));
b = int(b1 + double(i * (b2 - b1) / item->rc.bottom - item->rc.top));
Brush = CreateSolidBrush(RGB(r, g, b));
temp.left = 0;
temp.top = i;
temp.right = item->rc.right - item->rc.left;
temp.bottom = i + 1;
FillRect(hdcmem, &temp, Brush);
DeleteObject(Brush);
}
HBRUSH pattern = CreatePatternBrush(hbitmap);
DeleteDC(hdcmem);
DeleteObject(Brush);
DeleteObject(hbitmap);
return pattern;
}
/* Adds the rules in the .config files to the listbox. */
void GraphicalUserInterface::AddRulesToListbox(HWND hwnd)
{
SendMessage(GetDlgItem(hwnd, LISTVIEW_IP), LB_RESETCONTENT, 0, 0);
string env = getenv("ProgramFiles");
string path = env + "\\IP Firewall\\Profile_" + firewall.WIFI_SSID + ".config";
XMLReader reader(path);
if (!reader.IsReady())
{
string msg = "Failed to open the configuration file for this wifi setting! Error code: " + to_string(GetLastError());
MessageBox(0, msg.c_str(), "IF: Error", MB_OK | MB_ICONERROR);
return;
}
// List trough IP addresses and add them to the list.
for (int i = 0; i < reader.RetrieveIPAddressesInFile(); i++)
{
string IP = reader.RetrieveIP(i);
if (IP == "IP_NOT_FOUND")
continue;
SendMessage(GetDlgItem(hwnd, LISTVIEW_IP), LB_ADDSTRING, 0, (LPARAM)IP.c_str());
}
}