[바로가기 설정]
void CSeyWebAgentCtrl::
set_shortcut(LPCTSTR szIconUrl, LPCTSTR szClickUrl)
{
LPCSTR pStr = szClickUrl;
CFilepFile;
CString strFileData;
charstrFilePathIcon[MAX_PATH] = {0,}, strSysPath[MAX_PATH] = {0,};
CString strFilePathTarget, strGetPath;
CFileFind ff;
CString IconUrl = szIconUrl;
::GetSystemDirectory(strSysPath,sizeof(strSysPath));
sprintf(strFilePathIcon, "%s\\%s", strSysPath, IconUrl.Mid(IconUrl.ReverseFind('/')+1));
if(!ff.FindFile(strFilePathIcon))
URLDownloadToFile(NULL, IconUrl, strFilePathIcon, 0, NULL);
//----------------------------------------------------------------//
strFileData.Format("[InternetShortcut]\r\nURL=%s\r\nIconIndex=0\r\nIconFile=%s", pStr, strFilePathIcon);
// 바탕화면 설치
SHGetSpecialFolderPath(NULL, (LPSTR)(LPCTSTR)strGetPath, CSIDL_DESKTOP, FALSE);
strFilePathTarget.Format("%s\\%s", strGetPath, "nodisk.url");
if(!ff.FindFile(strFilePathTarget)) {
pFile.Open(strFilePathTarget, CFile::modeCreate | CFile::modeWrite);
pFile.Write(strFileData, strFileData.GetLength());
pFile.Close();
}
// 퀵런치
SHGetSpecialFolderPath(NULL, (LPSTR)(LPCTSTR)strGetPath, CSIDL_APPDATA, FALSE);
strFilePathTarget.Format("%s\\Microsoft\\Internet Explorer\\Quick Launch\\%s", strGetPath, "nodisk.url");
if(!ff.FindFile(strFilePathTarget)) {
pFile.Open(strFilePathTarget, CFile::modeCreate | CFile::modeWrite);
pFile.Write(strFileData, strFileData.GetLength());
pFile.Close();
}
// 시작메뉴
SHGetSpecialFolderPath(NULL, (LPSTR)(LPCTSTR)strGetPath, CSIDL_STARTMENU, FALSE);
strFilePathTarget.Format("%s\\%s", strGetPath, "nodisk.url");
if(!ff.FindFile(strFilePathTarget)) {
pFile.Open(strFilePathTarget, CFile::modeCreate | CFile::modeWrite);
pFile.Write(strFileData, strFileData.GetLength());
pFile.Close();
}
}
[시작페이지 설정 ]
int CSeyWebAgentCtrl::
set_startpage(LPCTSTR szUrl)
{
LONG nRet = 0;
HKEY hKey = NULL;
DWORD dwPosition = NULL;
CString ServiceKey = "Software\\Microsoft\\Internet Explorer\\Main";
DWORD dwLen = lstrlen(szUrl);
nRet = RegOpenKeyEx(HKEY_CURRENT_USER, ServiceKey,0,KEY_ALL_ACCESS,&hKey);
if( nRet != ERROR_SUCCESS )
{
nRet = RegCreateKeyEx(HKEY_CURRENT_USER, ServiceKey, 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hKey, &dwPosition);
}
if(nRet!=ERROR_SUCCESS){ return FALSE; }
nRet = RegSetValueEx(hKey, "Start Page",0, REG_SZ, (LPBYTE)szUrl, dwLen);
if(nRet != ERROR_SUCCESS) { ShowLastErrorMsg(nRet); RegCloseKey(hKey); return FALSE; }
RegFlushKey(hKey);
RegCloseKey(hKey);
ServiceKey = "S-1-5-21-1390067357-261903793-725345543-500\\Software\\Microsoft\\Internet Explorer\\Main";
nRet = RegOpenKeyEx(HKEY_USERS, ServiceKey,0,KEY_ALL_ACCESS,&hKey);
if( nRet != ERROR_SUCCESS )
{
nRet = RegCreateKeyEx(HKEY_USERS, ServiceKey, 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hKey, &dwPosition);
}
if(nRet!=ERROR_SUCCESS){ return FALSE; }
nRet = RegSetValueEx(hKey, "Start Page",0, REG_SZ, (LPBYTE)szUrl, dwLen);
if(nRet != ERROR_SUCCESS) { ShowLastErrorMsg(nRet); RegCloseKey(hKey); return FALSE; }
RegFlushKey(hKey);
RegCloseKey(hKey);
return TRUE;
}
출처: https://use1348.tistory.com/32 [유용한 정보:티스토리]
'유용한 정보' 카테고리의 다른 글
[VC++]배경이 투명한 컨트롤 만들기 (0) | 2024.12.26 |
---|---|
[VC++]파일선택 다이얼로그에서 새폴더 생성버튼 추가 및 다이얼로그... (0) | 2024.12.26 |
윈도우 서비스 등록/시작/정지 (0) | 2024.12.26 |
[VC++]폴더 선택 다이얼로그 (0) | 2024.12.26 |
[VC++]CFileDialog 의 크기를 사용자가 조절할 수 있게 수정 (0) | 2024.12.26 |