BOOL CSharpViewClientDlg::FileLink(const CString strPathObj,const CString strPathLink)
{
BOOL bRet = FALSE;
IShellLink* psl;
if (SUCCEEDED( CoCreateInstance(CLSID_ShellLink,
NULL,
CLSCTX_INPROC_SERVER,
IID_IShellLink,
(LPVOID*) &psl))
)
{
IPersistFile* ppf;
psl->SetPath(strPathObj);
if (SUCCEEDED(psl->QueryInterface( IID_IPersistFile, (LPVOID *) &ppf)))
{
WORD wsz[MAX_PATH];
MultiByteToWideChar(CP_ACP,
MB_PRECOMPOSED,
strPathLink,
-1,
wsz,
MAX_PATH);
if ( SUCCEEDED ( ppf->Save(wsz, TRUE) ) )
bRet = TRUE;
ppf->Release();
}
psl->Release();
}
return bRet;
}
void CSharpViewClientDlg::MainDialg_load()
{
// CString sSysinfor=m_SystemIfo.GetEventLoginfor();
//TRACE(sSysinfor);
CString sAutoPath=m_sCurrenDir+"//SharpViewClient.exe";
/* SetAutoRun(sAutoPath);//设置开机自动启动*/
char crEnVar[MAX_PATH];
::GetEnvironmentVariable("ALLUSERSPROFILE", crEnVar, MAX_PATH);
if (strlen(crEnVar) > 0)
{
CString destPath = CString(crEnVar);
destPath += "//「开始」菜单//程序//启动//";
destPath += "锐视网络行为规范";
destPath += ".lnk";
FileLink(sAutoPath, destPath);
}
else
{
::AfxMessageBox("can'n get Evironment-Variable",MB_OK);
gLog.WriteLog("can'n get Evironment-Variable");
}
vc添加应用程序快捷方式
最新推荐文章于 2018-07-19 16:55:13 发布