| |
208 |
208 |
_tcscpy(pszString, szStr); |
| |
209 |
209 |
|
| |
210 |
210 |
return pszString; |
| |
211 |
211 |
} |
| |
212 |
212 |
|
| |
213 |
213 |
bool CAppHelper::GetProgramDataPath(CString& rStrPath) |
| |
214 |
214 |
{ |
| |
215 |
215 |
HRESULT hResult = SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, rStrPath.GetBufferSetLength(_MAX_PATH)); |
| |
216 |
216 |
rStrPath.ReleaseBuffer(); |
| |
217 |
217 |
if(FAILED(hResult)) |
| |
218 |
218 |
return false; |
| |
219 |
219 |
|
| |
220 |
220 |
if(rStrPath.Right(1) != _T('\\')) |
| |
221 |
221 |
rStrPath += _T('\\'); |
| |
222 |
222 |
|
| |
223 |
223 |
|
| |
224 |
224 |
rStrPath += _T("\\Copy Handler"); |
| |
225 |
225 |
if(!CreateDirectory(rStrPath, NULL) && GetLastError() != ERROR_ALREADY_EXISTS) |
| |
226 |
226 |
return false; |
| |
227 |
227 |
|
| |
|
228 |
|
| |
|
229 |
rStrPath += _T("\\Tasks"); |
| |
|
230 |
if(!CreateDirectory(rStrPath, NULL) && GetLastError() != ERROR_ALREADY_EXISTS) |
| |
|
231 |
return false; |
| |
|
232 |
|
| |
228 |
233 |
return true; |
| |
229 |
234 |
} |
| |
230 |
235 |
|
| |
231 |
236 |
void CAppHelper::SetAutorun(bool bState) |
| |
232 |
237 |
{ |
| |
233 |
238 |
|
| |
234 |
239 |
HKEY hkeyRun; |
| |
235 |
240 |
if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"), 0, KEY_ALL_ACCESS, &hkeyRun) != ERROR_SUCCESS) |
| |
236 |
241 |
return; |
| |
237 |
242 |
|
| |
238 |
243 |
if (bState) |
| |
239 |
244 |
{ |
| |
240 |
245 |
TCHAR *pszPath=new TCHAR[_tcslen(m_pszProgramPath)+_tcslen(m_pszProgramName)+2]; |
| |
241 |
246 |
_tcscpy(pszPath, m_pszProgramPath); |
| |
242 |
247 |
_tcscat(pszPath, _T("\\")); |
| |
243 |
248 |
_tcscat(pszPath, m_pszProgramName); |
| |
244 |
249 |
|
| |
245 |
250 |
RegSetValueEx(hkeyRun, m_pszAppName, 0, REG_SZ, (BYTE*)pszPath, (DWORD)(_tcslen(pszPath)+1)*sizeof(TCHAR)); |
| |
246 |
251 |
|
| |
247 |
252 |
delete [] pszPath; |