Subversion Repositories Games.Chess Giants

Rev

Rev 189 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 189 Rev 192
Line 51... Line 51...
51
      RegCloseKey (hRegistryKey);
51
      RegCloseKey (hRegistryKey);
52
   }
52
   }
53
 
53
 
54
   // save application instance
54
   // save application instance
55
   hAppInstance = hInstance;
55
   hAppInstance = hInstance;
-
 
56
 
-
 
57
#ifdef NO_REGISTRATION
-
 
58
#else // !NO_REGISTRATION
-
 
59
   // does another Chess Giants instance exist ? If so, bring it to the front (note: allow this in debug mode)
-
 
60
   {
-
 
61
      HWND hOtherWnd = FindWindow (PROGRAM_NAME L" WndClass", NULL);
-
 
62
      if (IsWindow (hOtherWnd))
-
 
63
      {
-
 
64
         ShowWindow (hOtherWnd, SW_SHOW);
-
 
65
         BringWindowToTop (hOtherWnd);
-
 
66
         SetForegroundWindow (hOtherWnd);
-
 
67
         SetFocus (hOtherWnd);
-
 
68
         return (-1);
-
 
69
      }
-
 
70
   }
-
 
71
#endif // NO_REGISTRATION
56
 
72
 
57
   // find module and path names, and *IMPORTANT*, set the current working directory there
73
   // find module and path names, and *IMPORTANT*, set the current working directory there
58
   GetModuleFileName (NULL, app_pathname, WCHAR_SIZEOF (app_pathname));
74
   GetModuleFileName (NULL, app_pathname, WCHAR_SIZEOF (app_pathname));
59
   GetDirectoryPath (app_pathname, app_path);
75
   GetDirectoryPath (app_pathname, app_path);
60
   SetCurrentDirectoryW (app_path);
76
   SetCurrentDirectoryW (app_path);
-
 
77
 
-
 
78
   // see which Windows kernel we have by looking at kernel32.dll's file version. No error checking as this cannot fail.
-
 
79
   {
-
 
80
      uint8_t raw_version_data[256 + sizeof (VS_FIXEDFILEINFO)];
-
 
81
      VS_FIXEDFILEINFO *version_data;
-
 
82
      UINT version_data_size;
-
 
83
      GetFileVersionInfo (L"kernel32.dll", NULL, sizeof (raw_version_data), raw_version_data);
-
 
84
      VerQueryValue (raw_version_data, L"\\", (void **) &version_data, &version_data_size);
-
 
85
      kernel32_version = (((uint64_t) ((version_data->dwFileVersionMS >> 16) & 0xffff)) << 48)
-
 
86
                       | (((uint64_t) ((version_data->dwFileVersionMS >>  0) & 0xffff)) << 32)
-
 
87
                       | (((uint64_t) ((version_data->dwFileVersionLS >> 16) & 0xffff)) << 16)
-
 
88
                       | (((uint64_t) ((version_data->dwFileVersionLS >>  0) & 0xffff)) <<  0);
-
 
89
   }
-
 
90
 
-
 
91
   // see if we have VERY little memory, in which case complain
-
 
92
   // TODO
61
 
93
 
62
   // initialize stuff
94
   // initialize stuff
63
   terminate_everything = false;
95
   terminate_everything = false;
64
   hMainWnd = NULL;
96
   hMainWnd = NULL;
65
   hChatterChannelsWnd = NULL;
97
   hChatterChannelsWnd = NULL;
Line 124... Line 156...
124
   if (WSAStartup (MAKEWORD (2, 2), &wsa_data) != 0)
156
   if (WSAStartup (MAKEWORD (2, 2), &wsa_data) != 0)
125
   {
157
   {
126
      MessageBox (NULL, LOCALIZE (L"Error_NetworkInitializationFailed"), LOCALIZE (L"ImportantMessage"), MB_ICONERROR | MB_OK);
158
      MessageBox (NULL, LOCALIZE (L"Error_NetworkInitializationFailed"), LOCALIZE (L"ImportantMessage"), MB_ICONERROR | MB_OK);
127
      return (-1); // bomb out if network couldn't be initialized
159
      return (-1); // bomb out if network couldn't be initialized
128
   }
160
   }
-
 
161
 
-
 
162
   /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
 
163
   // TODO: measure amount of RAM. If < 1Gb total or < 500 Gb free, warn that some chess engines might refuse to run. //
-
 
164
   // FIXME: best thing would be to auto-adjust engine RAM usage according to what's available ?                      //
-
 
165
   /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
129
 
166
 
130
   // read configuration data
167
   // read configuration data
131
   Config_Load ();
168
   Config_Load ();
132
 
169
 
133
   // see if the program is registered
170
   // see if the program is registered