| |
247 |
247 |
|
| |
248 |
248 |
bool CAppHelper::IsInPortableMode() |
| |
249 |
249 |
{ |
| |
250 |
250 |
if(!m_optPortableMode.is_initialized()) |
| |
251 |
251 |
{ |
| |
252 |
252 |
|
| |
253 |
253 |
CString strPortableCfgPath = CString(GetProgramPath()) + _T("\\ch.xml"); |
| |
254 |
254 |
if(GetFileAttributes(strPortableCfgPath) == INVALID_FILE_ATTRIBUTES) |
| |
255 |
255 |
m_optPortableMode = false; |
| |
256 |
256 |
else |
| |
257 |
257 |
m_optPortableMode = true; |
| |
258 |
258 |
} |
| |
259 |
259 |
|
| |
260 |
260 |
return m_optPortableMode.get(); |
| |
261 |
261 |
} |
| |
262 |
262 |
|
| |
263 |
263 |
bool CAppHelper::SetAutorun(bool bEnable) |
| |
264 |
264 |
{ |
| |
265 |
265 |
|
| |
266 |
266 |
HKEY hkeyRun = NULL; |
| |
267 |
|
LSTATUS lStatus = ERROR_SUCCESS; |
| |
268 |
267 |
CString strValue; |
| |
269 |
268 |
CString strKey; |
| |
270 |
269 |
DWORD dwType = REG_SZ; |
| |
271 |
270 |
DWORD dwCount = _MAX_PATH * sizeof(TCHAR); |
| |
272 |
271 |
|
| |
273 |
|
lStatus = RegOpenKeyEx(HKEY_CURRENT_USER, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"), 0, KEY_QUERY_VALUE, &hkeyRun); |
| |
|
272 |
LSTATUS lStatus = RegOpenKeyEx(HKEY_CURRENT_USER, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"), 0, KEY_QUERY_VALUE, &hkeyRun); |
| |
274 |
273 |
if(lStatus != ERROR_SUCCESS) |
| |
275 |
274 |
return false; |
| |
276 |
275 |
|
| |
277 |
276 |
lStatus = RegQueryValueEx(hkeyRun, m_pszAppName, NULL, &dwType, (BYTE*)strValue.GetBufferSetLength(_MAX_PATH), &dwCount); |
| |
278 |
277 |
RegCloseKey(hkeyRun); |
| |
279 |
278 |
|
| |
280 |
279 |
if(lStatus != ERROR_SUCCESS && lStatus != ERROR_FILE_NOT_FOUND) |
| |
281 |
280 |
{ |
| |
282 |
281 |
strValue.ReleaseBuffer(0); |
| |
283 |
282 |
return false; |
| |
284 |
283 |
} |
| |
285 |
284 |
if(lStatus == ERROR_FILE_NOT_FOUND) |
| |
286 |
285 |
{ |
| |
287 |
286 |
strValue.ReleaseBuffer(0); |
| |
288 |
287 |
|
| |
289 |
288 |
|
| |
290 |
289 |
if(!bEnable) |
| |
291 |
290 |
return true; |
| |
292 |
291 |
|
| |
293 |
292 |
|