您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
BOOL CreateLink(LPWSTR szPath, LPCWSTR szLink) { HRESULT hres; IShellLink * psl; IPersistFile* ppf; WORD wsz[MAX_PATH]; CoInitialize(NULL); hres = CoCreateInstance( CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **)&psl); if (FAILED(hres)) { return FALSE; } psl->SetPath(szPath); psl->SetHotkey(MAKEWORD('M', HOTKEYF_SHIFT | HOTKEYF_CONTROL)); hres = psl->QueryInterface(IID_IPersistFile, (void**)&ppf); if (FAILED(hres)) return FALSE; //MultiByteToWideChar(CP_ACP, 0, szLink, -1, (LPWSTR)&wsz[0], MAX_PATH); hres = ppf->Save((LPCOLESTR)szLink, STGM_READWRITE); ppf->Release(); psl->Release(); CoUninitialize(); return TRUE; } VOID CreateShortCut(CString strAppName) { TCHAR DeskTopPath[MAX_PATH]; TCHAR currDirPath[MAX_PATH]; LPITEMIDLIST pidl = NULL; if (SUCCEEDED(SHGetFolderLocation(NULL, CSIDL_DESKTOP, NULL, 0, &pidl))) { SHGetPathFromIDList(pidl, DeskTopPath); IMalloc* pMalloc = NULL; ::SHGetMalloc(&pMalloc); pMalloc->Free(pidl); pMalloc->Release(); } CString tmp1 = GetApplicationPath2() + strAppName; TCHAR szFilename[MAX_PATH]; TCHAR szDrive[MAX_PATH]; TCHAR szPath[MAX_PATH]; TCHAR szExt[MAX_PATH]; _wsplitpath_s(tmp1, szDrive,255, szPath,255, szFilename,255, szExt,255); USES_CONVERSION; if (_access(W2A(tmp1), 0) == -1)return; CString tmp; tmp = DeskTopPath; tmp += "\\"; tmp += szFilename; tmp += _T(".lnk"); if (!CreateLink(tmp1.GetBuffer(), tmp)) AfxMessageBox(_T("创建快捷方式出错!")); tmp1.ReleaseBuffer(); }
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。