2 |
|
// |
3 |
|
// Douglas Thrift |
4 |
|
// |
5 |
< |
// $Id: VTBFileUtil2.h,v 1.2 2003/08/16 04:56:17 douglas Exp $ |
5 |
> |
// $Id: VTBFileUtil2.h,v 1.13 2003/08/25 08:08:18 douglas Exp $ |
6 |
|
|
7 |
|
#ifndef _VTBFileUtil_h_ |
8 |
|
#define _VTBFileUtil_h_ |
16 |
|
#include <sstream> |
17 |
|
#include <cctype> |
18 |
|
#include <vector> |
19 |
+ |
#include <set> |
20 |
+ |
#include <map> |
21 |
+ |
#include <cstdlib> |
22 |
|
|
23 |
|
#include <windows.h> |
24 |
+ |
#include <windowsx.h> |
25 |
+ |
#include <commctrl.h> |
26 |
+ |
#include <objbase.h> |
27 |
+ |
#include <shlobj.h> |
28 |
+ |
#include <shlwapi.h> |
29 |
+ |
|
30 |
+ |
#include "resource.h" |
31 |
|
|
32 |
|
using namespace std; |
33 |
|
|
34 |
+ |
enum Mode { none, disc, scan }; |
35 |
+ |
struct Gui |
36 |
+ |
{ |
37 |
+ |
HINSTANCE instance; |
38 |
+ |
HICON icon; |
39 |
+ |
int show; |
40 |
+ |
}; |
41 |
+ |
|
42 |
|
extern bool debug; |
43 |
|
extern string program; |
44 |
|
extern string programName; |
45 |
|
extern string programVersion; |
46 |
+ |
extern Gui gui; |
47 |
+ |
|
48 |
+ |
void usage(HWND parent = NULL); |
49 |
+ |
void version(HWND parent = NULL); |
50 |
+ |
|
51 |
+ |
inline string toAnsi(const wstring& wide) |
52 |
+ |
{ |
53 |
+ |
LPSTR buffer = new CHAR[wide.length() + 1]; |
54 |
+ |
|
55 |
+ |
WideCharToMultiByte(CP_ACP, 0, wide.c_str(), wide.length() + 1, buffer, |
56 |
+ |
wide.length() + 1, NULL, NULL); |
57 |
+ |
|
58 |
+ |
return buffer; |
59 |
+ |
} |
60 |
+ |
|
61 |
+ |
inline wstring toWide(const string& ansi) |
62 |
+ |
{ |
63 |
+ |
LPWSTR buffer = new WCHAR[ansi.length() + 1]; |
64 |
+ |
|
65 |
+ |
MultiByteToWideChar(CP_ACP, 0, ansi.c_str(), ansi.length() + 1, buffer, |
66 |
+ |
ansi.length() + 1); |
67 |
+ |
|
68 |
+ |
return buffer; |
69 |
+ |
} |
70 |
|
|
29 |
– |
void usage(HINSTANCE instance, HWND parent = NULL); |
30 |
– |
void version(HINSTANCE instance, HWND parent = NULL); |
71 |
|
inline void center(HWND window) |
72 |
|
{ |
73 |
|
RECT rect, dialog, desktop; |
84 |
|
+ (rect.bottom / 2), 0, 0, SWP_NOSIZE); |
85 |
|
} |
86 |
|
|
87 |
+ |
inline void error(HWND parent = NULL) |
88 |
+ |
{ |
89 |
+ |
LPVOID message; |
90 |
+ |
|
91 |
+ |
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | |
92 |
+ |
FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, |
93 |
+ |
LPTSTR(&message), 0, NULL); |
94 |
+ |
MessageBox(parent, LPCTSTR(message), programName.c_str(), MB_ICONERROR); |
95 |
+ |
LocalFree(message); |
96 |
+ |
} |
97 |
+ |
|
98 |
+ |
inline string format(DWORD value) |
99 |
+ |
{ |
100 |
+ |
ostringstream buffer; |
101 |
+ |
|
102 |
+ |
buffer << value; |
103 |
+ |
|
104 |
+ |
string format = buffer.str(); |
105 |
+ |
|
106 |
+ |
for (int index = format.length(), number = 0; index > 0; index -= 3, |
107 |
+ |
number += 3) |
108 |
+ |
{ |
109 |
+ |
if (index - 3 > 0) |
110 |
+ |
{ |
111 |
+ |
format.insert(index - 3, 1, ','); |
112 |
+ |
} |
113 |
+ |
} |
114 |
+ |
|
115 |
+ |
return format; |
116 |
+ |
} |
117 |
+ |
|
118 |
|
#endif // _VTBFileUtil_h_ |