MCPcopy Create free account
hub / github.com/ColorCop/ColorCop / InitApplication

Method InitApplication

ColorCop/ColorCop.cpp:169–206  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

167}
168
169BOOL CColorCopApp::InitApplication() {
170 // Detect portable‑mode command‑line switches (restores pre‑5.3 behavior)
171 CString cmd = GetCommandLine();
172 cmd.MakeLower();
173
174 if (cmd.Find(_T("-portable")) != -1 || cmd.Find(_T("--portable")) != -1 ||
175 cmd.Find(_T("/portable")) != -1 || cmd.Find(_T("/p")) != -1) {
176 m_PortableMode = true;
177 }
178 CString settingsFolder = GetSettingsFolder();
179 CString strInitFile = settingsFolder + INI_FILE; // "\Color_Cop.dat"
180
181 TRACE(_T("Portable mode: %d\n"), m_PortableMode);
182 TRACE(_T("INI path: %s\n"), strInitFile.GetString());
183
184 CFile file;
185 if (file.Open(strInitFile, CFile::modeRead)) {
186 try {
187 CArchive ar(&file, CArchive::load);
188 Serialize(ar);
189 } catch (CArchiveException* e) {
190 e->Delete();
191 TRACE(_T("Settings file corrupt or incompatible. Loading defaults.\n"));
192 LoadDefaultSettings();
193 ClipOrCenterWindowToMonitor(::GetForegroundWindow(), MONITOR_CENTER);
194 }
195 } else {
196 // First time running ColorCop
197 if (!m_PortableMode) {
198 CreateDirectory(settingsFolder, NULL);
199 }
200 LoadDefaultSettings();
201 ClipOrCenterWindowToMonitor(::GetForegroundWindow(), MONITOR_CENTER);
202 }
203
204
205 return CWinApp::InitApplication();
206}
207
208// Load all default settings. Called when no valid .DAT file exists
209void CColorCopApp::LoadDefaultSettings() {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected