Rev 130 | Rev 136 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 130 | Rev 133 | ||
---|---|---|---|
Line 21... | Line 21... | ||
21 | HDC hdc; |
21 | HDC hdc; |
22 | RECT rect; |
22 | RECT rect; |
23 | PAINTSTRUCT ps; |
23 | PAINTSTRUCT ps; |
24 | HBITMAP hbmTmp; |
24 | HBITMAP hbmTmp; |
25 | HDC hdcMem; |
25 | HDC hdcMem; |
- | 26 | HKEY hRegistryKey; |
|
26 | INPUT mousemove_input; |
27 | INPUT mousemove_input; |
27 | float previous_time; |
28 | float previous_time; |
28 | float screensaverwatchdog_feedtime; |
29 | float screensaverwatchdog_feedtime; |
29 | int frame_count; |
30 | int frame_count; |
30 | int array_index; |
31 | int array_index; |
31 | char *endptr; |
32 | char *endptr; |
32 | wchar_t app_pathname[MAX_PATH]; |
33 | wchar_t app_pathname[MAX_PATH]; |
33 | wchar_t font_pathname[MAX_PATH]; |
34 | wchar_t font_pathname[MAX_PATH]; |
34 | wchar_t temp_string[ |
35 | wchar_t temp_string[MAX_PATH]; |
- | 36 | DWORD ascii_buffersize; |
|
- | 37 | ||
- | 38 | // does an InstallerPath registry key exist? if so, it means we've just been installed |
|
- | 39 | ascii_buffersize = sizeof (temp_string); |
|
- | 40 | if ((RegOpenKeyEx (HKEY_CURRENT_USER, L"SOFTWARE\\Chess Giants", 0, KEY_READ | KEY_SET_VALUE, &hRegistryKey) == 0) |
|
- | 41 | && (RegQueryValueEx (hRegistryKey, L"InstallerPath", 0, NULL, (BYTE *) temp_string, &ascii_buffersize) == 0)) |
|
- | 42 | { |
|
- | 43 | temp_string[ascii_buffersize / sizeof (wchar_t)] = 0; // terminate the string ourselves (strings in the registry MAY have no null terminator) |
|
- | 44 | ||
- | 45 | // delete the installer |
|
- | 46 | DeleteFile (temp_string); |
|
- | 47 | ||
- | 48 | // delete the registry value and close the registry key |
|
- | 49 | RegDeleteValue (hRegistryKey, L"InstallerPath"); |
|
- | 50 | RegCloseKey (hRegistryKey); |
|
- | 51 | } |
|
35 | 52 | ||
36 | // save application instance |
53 | // save application instance |
37 | hAppInstance = hInstance; |
54 | hAppInstance = hInstance; |
38 | 55 | ||
39 | // find module and path names, and *IMPORTANT*, set the current working directory there |
56 | // find module and path names, and *IMPORTANT*, set the current working directory there |
Line 102... | Line 119... | ||
102 | // read configuration data |
119 | // read configuration data |
103 | Config_Load (); |
120 | Config_Load (); |
104 | 121 | ||
105 | // see if the program is registered |
122 | // see if the program is registered |
106 | is_registered = IsRegistrationCorrect (options.registration.user_email, options.registration.activation_code); |
123 | is_registered = IsRegistrationCorrect (options.registration.user_email, options.registration.activation_code); |
- | 124 | ||
- | 125 | // is it not ? if so, try to read alternate registration data from the registry |
|
- | 126 | if (!is_registered && (RegOpenKeyEx (HKEY_CURRENT_USER, L"SOFTWARE\\Chess Giants", 0, KEY_READ, &hRegistryKey) == 0)) |
|
- | 127 | { |
|
- | 128 | ascii_buffersize = sizeof (options.registration.user_email); // in bytes |
|
- | 129 | if (RegQueryValueEx (hRegistryKey, L"UserEmail", 0, NULL, (BYTE *) options.registration.user_email, &ascii_buffersize) == 0) |
|
- | 130 | options.registration.user_email[ascii_buffersize / sizeof (wchar_t)] = 0; // terminate the string ourselves (strings in the registry MAY have no null terminator) |
|
- | 131 | ascii_buffersize = sizeof (options.registration.activation_code); // in bytes |
|
- | 132 | if (RegQueryValueEx (hRegistryKey, L"ActivationCode", 0, NULL, (BYTE *) &options.registration.activation_code, &ascii_buffersize) != 0) |
|
- | 133 | options.registration.activation_code = 0; // if we can't read the activation code DWORD properly, reset it |
|
- | 134 | RegCloseKey (hRegistryKey); // once we've read the data we were interested in, close the registry key |
|
- | 135 | ||
- | 136 | // now check again if we're registered |
|
- | 137 | is_registered = IsRegistrationCorrect (options.registration.user_email, options.registration.activation_code); |
|
- | 138 | } |
|
107 | 139 | ||
108 | // uncomment the two lines below to test the registration code |
140 | // uncomment the two lines below to test the registration code |
109 | //DialogBox_Registration (); |
141 | //DialogBox_Registration (); |
110 | //return (0); |
142 | //return (0); |
111 | 143 |