我想把mididll.cpl文件从当前目录Copy到d:\Winnt\system32下,用下面的语句不能成功,CopyFile返回值为TRUE,但文件没有Copy到指定的目录下。strcpy(sSysDir,"d:\\winnt\\system32");
strcat(sSysDir,"\\mididll.CPL");
if(!CopyFile(strInfFileName,sSysDir,FALSE))
{
AfxMessageBox("error");
return ;
}而下面却成功
strcpy(sSysDir,"d:\\winnt");
strcat(sSysDir,"\\mididll.CPL");
if(!CopyFile(strInfFileName,sSysDir,FALSE))
{
AfxMessageBox("error");
return ;
}
strcat(sSysDir,"\\mididll.CPL");
if(!CopyFile(strInfFileName,sSysDir,FALSE))
{
AfxMessageBox("error");
return ;
}而下面却成功
strcpy(sSysDir,"d:\\winnt");
strcat(sSysDir,"\\mididll.CPL");
if(!CopyFile(strInfFileName,sSysDir,FALSE))
{
AfxMessageBox("error");
return ;
}
TCHAR sSysDir[256];
memset(sSysDir,0,256*sizeof(TCHAR));
strcpy(sSysDir,"c:\\windows\\system32");
strcat(sSysDir,"\\hello.txt");
if(!CopyFile(strInfFileName,sSysDir,FALSE))
{
AfxMessageBox("error");
return TRUE ;
}
可以啊!我的系统是XP,在C盘,所以我修改了你的代码。
strcpy(sSysDir,"d:\\winnt\\system32");
strcat(sSysDir,"\\mididll.CPL");
if(!CopyFile(strInfFileName,sSysDir,FALSE))
{
AfxMessageBox("error");
return ;
}
是对的
GetSystemDirectory(SysPath,MAX_PATH);//直接得到系统目录
if(!CopyFile((LPCTSTRstrInfFileName,,(LPCTSTR)SysPath,0))
{
AfxMessageBox("error");
return ;
}
char SysPath[MAX_PATH];
GetSystemDirectory(SysPath,MAX_PATH);//直接得到系统目录
strcat(SysPath,"\\mididll.CPL");
if(!CopyFile((LPCTSTRstrInfFileName,,(LPCTSTR)SysPath,0))
{
AfxMessageBox("error");
return ;
}