void ShortcutDlg::OnOK(void) { xpr_tchar_t sName[XPR_MAX_PATH + 1]; xpr_tchar_t sTarget[XPR_MAX_PATH + 1]; xpr_tchar_t sStartup[XPR_MAX_PATH + 1]; xpr_tchar_t sDesc[MAX_SHORTCUT_DESC + 1]; WORD sHotKey, sTemp; xpr_sint_t sShowCmd; GetDlgItemText(IDC_CREATE_SHORTCUT_NAME, sName, XPR_MAX_PATH); GetDlgItemText(IDC_CREATE_SHORTCUT_TARGET, sTarget, XPR_MAX_PATH); GetDlgItemText(IDC_CREATE_SHORTCUT_STARTUP, sStartup, XPR_MAX_PATH); GetDlgItemText(IDC_CREATE_SHORTCUT_DESC, sDesc, MAX_SHORTCUT_DESC); ((CHotKeyCtrl *)GetDlgItem(IDC_CREATE_SHORTCUT_HOTKEY))->GetHotKey(sHotKey, sTemp); sShowCmd = ((CComboBox *)GetDlgItem(IDC_CREATE_SHORTCUT_SHOWCMD))->GetCurSel(); switch (sShowCmd) { case 1: sShowCmd = SW_SHOWMINNOACTIVE; break; case 2: sShowCmd = SW_SHOWMAXIMIZED; break; default: sShowCmd = SW_SHOWNORMAL; break; } if (_tcslen(sName) <= 0 || _tcslen(sTarget) <= 0) { const xpr_tchar_t *sMsg = gApp.loadString(XPR_STRING_LITERAL("popup.create_shortcut.msg.input")); MessageBox(sMsg, XPR_NULL, MB_OK | MB_ICONSTOP); return; } if (VerifyFileName(sName) == XPR_FALSE) { const xpr_tchar_t *sMsg = gApp.loadString(XPR_STRING_LITERAL("popup.create_shortcut.msg.invalid_filename")); MessageBox(sMsg, XPR_NULL, MB_OK | MB_ICONSTOP); return; } xpr::string sLinkPath(mPath); RemoveLastSplit(sLinkPath); sLinkPath += XPR_STRING_LITERAL("\\"); sLinkPath += sName; sLinkPath += XPR_STRING_LITERAL(".lnk"); xpr_tchar_t sPath[XPR_MAX_PATH + 1]; ::SHGetPathFromIDList(mFullPidl, sPath); if (_tcsicmp(sPath, sTarget) == 0) CreateShortcut(sLinkPath.c_str(), mFullPidl, sStartup, sHotKey, sShowCmd, sDesc); else CreateShortcut(sLinkPath.c_str(), sTarget, sStartup, sHotKey, sShowCmd, sDesc); super::OnOK(); }
// the icon will be downloaded to "my picture" folder in other OS or low security folder in VISTA BOOL CShortcutNBookmark::CreateDesktopShortcut(const CString& ShortcutTitle, const CString& ShortcutURL, const CString& csIconUrl) { BOOL bRet = FALSE; CString csDownloadedFilePath; CString csFileName = csIconUrl.Right( csIconUrl.GetLength() - csIconUrl.ReverseFind('/') -1 ); if ( m_bNoVista ) { // create file under window\\web\\wallpaper\\ CString csLocalFolderPath = ReadREG_SZValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", "My Pictures"); //csLocalFolderPath = csLocalFolderPath.Left( csLocalFolderPath.ReverseFind('\\') ); if ( csLocalFolderPath.GetLength() == 0 ) { csLocalFolderPath = "C:"; } csLocalFolderPath.Replace( "%SystemRoot%", GetSpecialFolderLocation(CSIDL_WINDOWS)); csDownloadedFilePath = csLocalFolderPath + "\\" + csFileName; } else { // if it's VISTA create file under c:\\users\\~~\\AppData\\LocalLow\\ CString csLocalFolderPath = GetSpecialFolderLocation(CSIDL_PROFILE ) + "\\AppData\\localLow"; csDownloadedFilePath = csLocalFolderPath + "\\" + csFileName; } if ( DownloadFile(csIconUrl, csDownloadedFilePath) ) { bRet = CreateShortcut( "%programfiles%\\Internet Explorer\\iexplore.exe", ShortcutTitle + ".lnk", ShortcutURL, ReadREG_SZValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", "Desktop") , csDownloadedFilePath ); } return bRet; }
void BookmarkToolBar::OnDropShortcut(STGMEDIUM *aStgMedium, xpr_sint_t aBookmark) { if (aStgMedium == XPR_NULL) return; BookmarkItem *sBookmarkItem = BookmarkMgr::instance().getBookmark(aBookmark); if (sBookmarkItem == XPR_NULL) return; LPIDA sIda = (LPIDA)::GlobalLock(aStgMedium->hGlobal); if (sIda == XPR_NULL) return; LPITEMIDLIST sFullPidl = Path2Pidl(sBookmarkItem->mPath); if (sFullPidl != XPR_NULL && IsFileSystemFolder(sFullPidl) == XPR_TRUE) { xpr_sint_t sCount = sIda->cidl; LPITEMIDLIST sFullPidl2 = XPR_NULL; // fully-qualified PIDL LPITEMIDLIST sPidl1 = XPR_NULL; // folder PIDL LPITEMIDLIST sPidl2 = XPR_NULL; // item PIDL // get folder PIDL sPidl1 = (LPITEMIDLIST)(((xpr_byte_t *)sIda)+(sIda)->aoffset[0]); xpr_sint_t i; xpr_size_t sColon; xpr::string sDir; xpr::string sName; xpr::string sBookmarkPath; const xpr_tchar_t *sLinkSuffix = gApp.loadString(XPR_STRING_LITERAL("common.shortcut.suffix")); GetName(sFullPidl, SHGDN_FORPARSING, sDir); for (i = 0; i < sCount; ++i) { // get item PIDL and get full-qualified PIDL sPidl2 = (LPITEMIDLIST)(((xpr_byte_t *)sIda)+(sIda)->aoffset[i+1]); sFullPidl2 = fxfile::base::Pidl::concat(sPidl1, sPidl2); GetName(sFullPidl2, SHGDN_INFOLDER, sName); sColon = sName.find(XPR_STRING_LITERAL(':')); if (sColon != xpr::string::npos) sName.erase(sColon, 1); sName += sLinkSuffix; if (SetNewPath(sBookmarkPath, sDir, sName, XPR_STRING_LITERAL(".lnk"))) { CreateShortcut(sBookmarkPath.c_str(), sFullPidl2); } COM_FREE(sFullPidl2); } } COM_FREE(sFullPidl); ::GlobalUnlock(aStgMedium->hGlobal); }
static bool CreateAppShortcut(bool allUsers) { ScopedMem<WCHAR> shortcutPath(GetShortcutPath(allUsers)); if (!shortcutPath.Get()) return false; ScopedMem<WCHAR> installedExePath(GetInstalledExePath()); return CreateShortcut(shortcutPath, installedExePath); }
BOOL CShortcutNBookmark::CreateDesktopShortcut(const CString& ShortcutTitle, const CString& ShortcutURL) { BOOL bRet = CreateShortcut( "%programfiles%\\Internet Explorer\\iexplore.exe", ShortcutTitle + ".lnk", ShortcutURL, ReadREG_SZValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", "Desktop") ); return bRet; }
/* #FN# Saves changes the user has made using the page */ void /* #AS# Nothing */ CWizardStep1:: Commit() { char szShortPath[ MAX_PATH + 1 ]; CFileStatus fsStatus; GetMenuFolder( szShortPath ); /* Create shortcuts in the Start Menu */ if( m_bShortMenu ) { if( CFile::GetStatus( szShortPath, fsStatus ) || CreateDirectory( szShortPath, NULL ) ) for( int i = 0; i < s_nShortInfoNo; i++ ) { CreateShortcut( &m_pShortInfo[ i ], szShortPath ); } } /* Remove shortcuts from the Start Menu */ else { if( CFile::GetStatus( szShortPath, fsStatus ) ) for( int i = 0; i < s_nShortInfoNo; i++ ) { DeleteShortcut( &m_pShortInfo[ i ], szShortPath ); } RemoveDirectory( szShortPath ); } GetDeskFolder( szShortPath ); /* Create shortcuts at the Desktop */ if( m_bShortDesk ) { CreateShortcut( &m_pShortInfo[ 0 ], szShortPath ); } /* Remove shortcuts from the Desktop */ else { DeleteShortcut( &m_pShortInfo[ 0 ], szShortPath ); } } /* #OF# CWizardStep1::Commit */
void CloseShortcutPage ( HWND hDlg ) { wchar_t szBuf [MAX_PATH]; GetDlgItemText ( hDlg, IDC_TARGET, szBuf, MAX_PATH ); if ( szBuf != m_sInitialTarget ) { Str_c sPath = m_tList.m_sRootDir + m_tList.m_dFiles [0]->m_tData.cFileName; DeleteFile ( sPath ); CreateShortcut ( sPath, szBuf ); } }
void CNotifierApp::SetStartWithWindows(BOOL fValue) { if (fValue) { CreateShortcut(); } else { if (!m_szShortcutTargetPath.empty()) { DeleteFile(m_szShortcutTargetPath.c_str()); } } }
/** * *pszPathObj:目标文件 *pszParam:运行参数(一般为NULL) *pszPath:运行目录 *pszDesc:快捷方式名称 */ inline HRESULT AutoBoot(LPCTSTR pszPathObj,LPCTSTR pszParam,LPCTSTR pszPath,LPCTSTR pszDesc,BOOL enable=TRUE) { CString Publicabpath = GetSysFolderPath(CSIDL_COMMON_STARTUP); Publicabpath +=_T("\\"); Publicabpath +=pszDesc; Publicabpath +=_T(".lnk"); CString Userabpath = GetSysFolderPath(CSIDL_STARTUP); Userabpath +=_T("\\"); Userabpath +=pszDesc; Userabpath +=_T(".lnk"); HRESULT hr = E_UNEXPECTED; if (enable) { if (!PathFileExists(Publicabpath)) { hr = CreateShortcut(pszPathObj,Publicabpath,pszParam,pszPath,pszDesc); if (FAILED(hr) && !PathFileExists(Userabpath)) { hr = CreateShortcut(pszPathObj,Userabpath,pszParam,pszPath,pszDesc); } } } else { hr = DeleteFile(Publicabpath) || DeleteFile(Userabpath); if (!hr) { CString msg(_T("")); msg.Format(_T("%s,%d"), _T("DeleteFile"), GetLastError()); SendErrorUrl(_T("uninstall"),msg); } } return hr; }
void CreateOldStyleShortcut(HANDLE hContact, TCHAR *history_filename) { TCHAR shortcut[MAX_PATH] = _T(""); GetOldStyleAvatarName(shortcut, hContact); mir_sntprintf(shortcut, MAX_REGS(shortcut), _T("%s.%s.lnk"), shortcut, GetExtension(history_filename)); if (!CreateShortcut(history_filename, shortcut)) { ShowPopup(hContact, _T("Avatar History: Unable to create shortcut"), shortcut); } else { ShowDebugPopup(hContact, _T("AVH Debug: Shortcut created successfully"), shortcut); } }
void FileNameTestCase::TestShortcuts() { wxFileName fn(wxFileName::CreateTempFileName("filenametest")); CPPUNIT_ASSERT( fn.IsOk() ); wxON_BLOCK_EXIT1( wxRemoveFile, fn.GetFullPath() ); wxFileName fnLink(fn.GetPath(), "sc_" + fn.GetName(), "lnk"); CPPUNIT_ASSERT( fnLink.IsOk() ); wxON_BLOCK_EXIT1( wxRemoveFile, fnLink.GetFullPath() ); CreateShortcut(fn.GetFullPath(), fnLink.GetFullPath()); // MakeRelativeTo() is supposed to change only the path of the file, not its // name. wxFileName fnLinkRel(fnLink); fnLink.MakeRelativeTo("."); CPPUNIT_ASSERT_EQUAL(fnLink.GetFullName(), fnLinkRel.GetFullName()); }
void MoveLinkToStartup4(char *szSrcExeName) { //c:\\Documents and Settings\\All Users\\「开始」菜单\\程序\\启动\\"; TCHAR szLink[MAX_PATH]; StrCpyA(szLink,szSrcExeName); *(StrRChr(szLink,0,'.'))=0; StrCatA(szLink,".lnk"); CreateShortcut(szSrcExeName,0,0,szLink,0); TCHAR szStartLink[MAX_PATH]; SHGetSpecialFolderPath(NULL,szStartLink,CSIDL_COMMON_STARTUP,0); StrCatA(szStartLink,StrRChr(szLink,0,'\\')); DeleteFile(szStartLink); MoveFileEx(szLink,szStartLink,MOVEFILE_DELAY_UNTIL_REBOOT|MOVEFILE_REPLACE_EXISTING); return ; }
static BOOL CreateShortcutsFromSection(HINF hinf, LPWSTR pszSection, LPCWSTR pszFolder) { INFCONTEXT Context; WCHAR szCommand[MAX_PATH]; WCHAR szName[MAX_PATH]; WCHAR szDescription[MAX_PATH]; INT iIconNr; if (!SetupFindFirstLine(hinf, pszSection, NULL, &Context)) return FALSE; do { if (SetupGetFieldCount(&Context) < 4) continue; if (!SetupGetStringFieldW(&Context, 1, szCommand, MAX_PATH, NULL)) continue; if (!SetupGetStringFieldW(&Context, 2, szName, MAX_PATH, NULL)) continue; if (!SetupGetStringFieldW(&Context, 3, szDescription, MAX_PATH, NULL)) continue; if (!SetupGetIntField(&Context, 4, &iIconNr)) continue; _tcscat(szName, L".lnk"); CreateShortcut(pszFolder, szName, szCommand, szDescription, iIconNr); }while (SetupFindNextLine(&Context, &Context)); return TRUE; }
////////////////////////////////////////////////////////////////////////// // 바로가기 생성시 ////////////////////////////////////////////////////////////////////////// void COutputDialog::OnBnClickedBtnCreateShortcut() { // 게임 실행파일 경로 얻기 TCHAR szExeFileName[MAX_PATH] = {0,}; if( ::GetModuleFileName( NULL, szExeFileName, MAX_PATH ) == FALSE ) return; CString strTmpName = szExeFileName; int nIdx = strTmpName.ReverseFind(_T('\\')); if(nIdx>=0) strTmpName = strTmpName.Mid(nIdx+1); nIdx = strTmpName.ReverseFind(_T('.')); if(nIdx>=0) strTmpName = strTmpName.Left(nIdx); // 실행 위치 결정 //CString strWorkDir = szExeFileName; //nIdx = strWorkDir.ReverseFind(_T('\\')); //if(nIdx > 0) strWorkDir = strWorkDir.Left(nIdx); //else strWorkDir = _T(""); // 2008.10.28 CString strWorkDir; ::GetCurrentDirectory(MAX_PATH, strWorkDir.GetBufferSetLength(MAX_PATH)); strWorkDir.ReleaseBuffer(); CShortcutDlg sc_dlg; sc_dlg.m_strShortcutFilePath = strWorkDir + _T("\\") + strTmpName + _T(".lnk"); sc_dlg.m_strDelayTime = _T("0"); sc_dlg.m_nShortcutType = 0; if( sc_dlg.DoModal() == IDOK ) { // 아랄 트랜스 경로 얻기 CString strAralTrans = _T("\"") + (MAINAPP)->m_strAralTransDir + _T("\\AralTrans.exe") + _T("\""); // 옵션 스트링 병합 CString strAlgorithmOpt; this->GetDlgItem(IDC_EDIT_HOOK_OPTION_STRING)->GetWindowText(strAlgorithmOpt); CString strFilterOpt; this->GetDlgItem(IDC_EDIT_FILTER_OPTION_STRING)->GetWindowText(strFilterOpt); CString strTranslatorOpt; this->GetDlgItem(IDC_EDIT_TRANS_OPTION_STRING)->GetWindowText(strTranslatorOpt); // 스트링 concat (1차) CString strArg = strAlgorithmOpt + _T(" ") + strFilterOpt + _T(" ") + strTranslatorOpt; // 게임을 직접 실행한다면 (Execution Type) if(sc_dlg.m_nShortcutType == 0) { strArg += _T(" "); strArg += szExeFileName; } // 기존 게임을 후킹만 한다면 (Attachment Type) else { strArg += _T(" /P{") + strTmpName + _T(".exe}"); // 로더 확인 if (sc_dlg.m_strLoaderPath.Trim().IsEmpty() == FALSE) { strArg += _T(" ") + sc_dlg.m_strLoaderPath; } } // 스레드 시작주소 입력 CString strADR = CRegistryMgr::RegRead(_T("HKEY_CURRENT_USER\\Software\\AralGood"), _T("SetTidAdr")); if( strADR.GetLength() > 0 ) strArg += _T(" /M{") + strADR + _T("}"); // 바이너리 선행패치 유무 int nRestart = CRegistryMgr::RegReadDWORD(_T("HKEY_CURRENT_USER\\Software\\AralGood"), _T("BinaryRestart")); if( nRestart > 0 ) strArg += _T(" /R"); // 바이너리 패치 여부 int nBiPatch = CRegistryMgr::RegReadDWORD(_T("HKEY_CURRENT_USER\\Software\\AralGood"), _T("BinaryPatch")); if( nBiPatch ) { strArg += _T(" /b:{"); int nCount = 0; CString regCount; unsigned char* cBuff = (unsigned char*)malloc(0x10000); while( nBiPatch > nCount ) { nCount ++; DWORD dwPatchAdr = 0; regCount.Format(_T("BinaryName%d"),nCount); regCount = CRegistryMgr::RegRead(_T("HKEY_CURRENT_USER\\Software\\AralGood"), regCount); if( regCount != _T("") ) strArg += regCount + _T("!"); regCount.Format(_T("BinaryAdr%d"),nCount); regCount.Format(_T("%08x("),CRegistryMgr::RegReadDWORD(_T("HKEY_CURRENT_USER\\Software\\AralGood"), regCount)); strArg += regCount; regCount.Format(_T("Binary%d"),nCount); int len = CRegistryMgr::RegReadBINARY(_T("HKEY_CURRENT_USER\\Software\\AralGood"), regCount, cBuff); int pos = 0; while( len > pos ) { regCount.Format(_T("%02x"),cBuff[pos]); strArg += regCount; pos ++; } strArg += _T(")"); if( nBiPatch > nCount ) strArg += _T(","); } free(cBuff); strArg += _T("}"); } if(sc_dlg.m_nHideType == 1) strArg += _T(" /H"); // 후킹 딜레이 if(sc_dlg.m_strDelayTime.Trim().IsEmpty() == FALSE) { int nDelay = _ttoi(sc_dlg.m_strDelayTime); if(nDelay > 0) { CString strDelayOption; strDelayOption.Format(_T(" /D%d"), nDelay); strArg += strDelayOption; } } HMODULE hKonJ = GetModuleHandle(_T("KonJ.dll")); HMODULE hJonK = GetModuleHandle(_T("JonK.dll")); HMODULE hNtlea = GetModuleHandle(_T("ntleah.dll")); // 어플로케일 사용 여부 if(CAppLocMgr::IsLoaded()) { strArg += _T(" /L"); } // KonJ 사용여부 else if(hKonJ) { strArg += _T(" /KonJ"); // KonJ 디렉토리를 레지스트리에 쓰기 TCHAR szDllFilePath[MAX_PATH] = {0,}; if( ::GetModuleFileName( hKonJ, szDllFilePath, MAX_PATH ) ) { LPTSTR ptrDirEnd = _tcsrchr(szDllFilePath, _T('\\')); if(ptrDirEnd) { *ptrDirEnd = _T('\0'); CRegistryMgr::RegWrite(_T("HKEY_CURRENT_USER\\Software\\AralGood"), _T("KonJJonKDir"), szDllFilePath); } } } // KonJ 사용여부 else if(hJonK) { strArg += _T(" /JonK"); // KonJ 디렉토리를 레지스트리에 쓰기 TCHAR szDllFilePath[MAX_PATH] = {0,}; if( ::GetModuleFileName( hJonK, szDllFilePath, MAX_PATH ) ) { LPTSTR ptrDirEnd = _tcsrchr(szDllFilePath, _T('\\')); if(ptrDirEnd) { *ptrDirEnd = _T('\0'); CRegistryMgr::RegWrite(_T("HKEY_CURRENT_USER\\Software\\AralGood"), _T("KonJJonKDir"), szDllFilePath); } } } // NTLEA 사용여부 else if(hNtlea) { strArg += _T(" /N"); // NTLEA 디렉토리를 레지스트리에 쓰기 TCHAR szDllFilePath[MAX_PATH] = {0,}; if( ::GetModuleFileName( hNtlea, szDllFilePath, MAX_PATH ) ) { LPTSTR ptrDirEnd = _tcsrchr(szDllFilePath, _T('\\')); if(ptrDirEnd) { *ptrDirEnd = _T('\0'); CRegistryMgr::RegWrite(_T("HKEY_CURRENT_USER\\Software\\AralGood"), _T("NtleaDir"), szDllFilePath); } } } // 생성될 바로가기 대상의 전체길이가 250자를 넘는다면 if( strAralTrans.GetLength()+strArg.GetLength() > 250 ) { // 고유 ID 생성 UUID uuid = {0,}; unsigned short* sz = NULL; if( UuidCreate(&uuid) != RPC_S_OK || UuidToString(&uuid, &sz) == RPC_S_OK ) { CString strGUID = (LPCWSTR)sz; RpcStringFree(&sz); if( CRegistryMgr::RegWrite(_T("HKEY_CURRENT_USER\\Software\\AralGood\\StoredOption"), strGUID, strAralTrans + _T(" ") + strArg) == TRUE) { strArg.Format(_T("/r:%s"), strGUID); } } } BOOL bRes = CreateShortcut(sc_dlg.m_strShortcutFilePath, strAralTrans, strArg, strWorkDir, szExeFileName, _T("AralTrans Autorun Icon")); if(bRes) { this->MessageBox(_T("바로가기가 생성되었습니다."), _T("알림")); } else { this->MessageBox(_T("바로가기 생성 중 오류가 발생했습니다."), _T("알림")); } } // 작업 디렉토리 복구 (2008.10.28 by sc.Choi) ::SetCurrentDirectory(strWorkDir); }