ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/proj/trunk/VTBFileUtil2/License.cxx
Revision: 291
Committed: 2003-09-05T01:57:00-07:00 (21 years, 9 months ago) by douglas
File size: 2546 byte(s)
Log Message:
Editing is rich.

File Contents

# Content
1 // Vance Thrift and Biller File Utility 2
2 //
3 // Douglas Thrift
4 //
5 // $Id: License.cxx,v 1.1 2003/09/05 08:57:00 douglas Exp $
6
7 #include "License.h"
8
9 License::License()
10 {
11 number = count++;
12
13 licenses.insert(pair<unsigned, License*>(number, this));
14 }
15
16 License::~License()
17 {
18 licenses.erase(number);
19 }
20
21 void License::display(HWND parent)
22 {
23 DialogBoxParam(gui.instance, MAKEINTRESOURCE(IDD_LICENSE), parent, window,
24 number);
25 }
26
27 void License::check(HWND parent)
28 {
29 HKEY key;
30
31 if (LONG code = RegCreateKeyEx(HKEY_CURRENT_USER,
32 "Software\\DouglasThrift\\VTBFileUtil2", 0, NULL,
33 REG_OPTION_NON_VOLATILE, KEY_QUERY_VALUE | KEY_SET_VALUE, NULL, &key,
34 NULL) == ERROR_SUCCESS)
35 {
36 DWORD type, data, size = sizeof(data);
37
38 if (RegQueryValueEx(key, "LastLicenseDate", NULL, &type, LPBYTE(&data),
39 &size) == ERROR_SUCCESS)
40 {
41 if (type != REG_DWORD)
42 {
43 data = 0;
44 }
45 }
46 else
47 {
48 data = 0;
49 }
50
51 if (debug) cerr << "data = {\n"
52 << " month = " << LOWORD(data) << "\n"
53 << " year = " << HIWORD(data) << "\n"
54 << "}\n";
55
56 SYSTEMTIME time;
57
58 GetLocalTime(&time);
59
60 if (debug) cerr << "time = {\n"
61 << " month = " << time.wMonth << "\n"
62 << " year = " << time.wYear << "\n"
63 << "}\n";
64
65 if (LOWORD(data) != time.wMonth || HIWORD(data) != time.wYear)
66 {
67 display(parent);
68
69 data = MAKELONG(time.wMonth, time.wYear);
70
71 if (code = RegSetValueEx(key, "LastLicenseDate", 0, REG_DWORD,
72 LPBYTE(&data), sizeof(data)) != ERROR_SUCCESS)
73 {
74 error(parent, code);
75 }
76 }
77
78 RegCloseKey(key);
79 }
80 else
81 {
82 error(parent, code);
83 }
84 }
85
86 unsigned License::count = 0;
87 map<unsigned, License*> License::licenses;
88 map<HWND, License*> License::windows;
89
90 INT_PTR License::window(HWND dialog, UINT msg, WPARAM w, LPARAM l)
91 {
92 map<HWND, License*>::iterator itor = windows.find(dialog);
93 License* data = itor->second;
94
95 switch (msg)
96 {
97 case WM_INITDIALOG:
98 center(dialog);
99 SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(gui.icon));
100 SendMessage(dialog, WM_SETTEXT, 0, LPARAM(programName.c_str()));
101
102 {
103 map<unsigned, License*>::iterator itor = licenses.find(l);
104
105 windows.insert(pair<HWND, License*>(dialog, itor->second));
106
107 data = itor->second;
108 }
109
110 /* {
111 LoadLibrary("riched20.dll");
112 CreateWindowEx(WS_EX_CLIENTEDGE, RICHEDIT_CLASS, "#1051", WS_CHILD
113 | WS_VISIBLE, 30, 33, 457, 242, dialog, NULL, gui.instance, 0);
114 }*/
115 break;
116 case WM_COMMAND:
117 switch (LOWORD(w))
118 {
119 case IDCANCEL:
120 case IDOK:
121 EndDialog(dialog, w);
122 return TRUE;
123 break;
124 }
125 break;
126 }
127
128 return FALSE;
129 }