VC中怎样Copy当前程序到启动目录

来源:百度知道 编辑:UC知道 时间:2024/09/24 03:54:55
我想将当前运行程序的快捷方式拷贝到系统启动目录下,该怎么做?
我的CopyFile()怎么没法用?下面是我的代码。请大侠指教啊!!!
void CDlgFlashDlg::OnBtnCopy()
{
// TODO: Add your control notification handler code here
TCHAR szDirPath[] = _T("D:\\zdf\\zdf.txt"); //from
TCHAR szNewPath[]=_T("E:\\Delver\\"); //to

if(CopyFile(szDirPath,szNewPath,true))
AfxMessageBox("copy");
else
AfxMessageBox("no copy");
}
两位朋友的方法都对!非常感谢!
请问怎样生成某一应用程序的快捷方式呢?因为快捷方式往往在电脑启动时更常用。

BOOL DataManageDlg::CopyFiles(CString sForm, CString sTo)拷贝函数
{
BOOL isb;
SHFILEOPSTRUCT fo;
TCHAR szFrom[MAX_PATH+1];
TCHAR szTo[MAX_PATH+1];

ZeroMemory(&fo, sizeof(fo));
ZeroMemory(szFrom, sizeof(szFrom));
ZeroMemory(szTo, sizeof(szTo));

// CString strPath;
isb=false;
CString str1;
// strPath = _T("D:\\vcvc\\ado10\\Debug\\");
// strPath += _T("1.txt");
_tcscpy(szFrom, sForm);
_tcscpy(szTo, sTo);
fo.hwnd=this->m_hWnd;
fo.wFunc = FO_COPY;
fo.pFrom = szFrom;
fo.pTo = szTo;
// fo.fFlags = FOF_SIMPLEPROGRESS;
// fo.fFlags = FOF_ALLOWUNDO;
fo.fFlags=FOF_NOCONFIRMATION;
::SHFileOperation(&fo);
isb=true;
return isb;
}
启动路径C:\Documents and Settings\All Users\「开始」菜单\程序\启动
///////////////////////////////////////////////
/////////////////