我想在我的系统中安装一种新的字体,但是在我的代码中出现错误,我找不到我犯的错误。在我调用CopyFile之后,该文件不存在于C:\ Windows \ Fonts中。可以给我一些建议吗?谢谢。 这里是我的代码:为什么我不能将字体文件复制到c: Windows Fonts中CopyFile
`//the source file
string sSourceDir = "F:\\my_job\\font\\";
//the file name
string sFontFileName = "jdqw.TTF";
string sFontName = "jdqw";
TCHAR sWinDir[MAX_PATH];
GetWindowsDirectory(sWinDir, MAX_PATH);
string sFontDir(sWinDir);
//make the path like C:\\Windows\\Fonts
sFontDir += "\\Fonts\\";
string sFOTFile = sFontDir;
sFOTFile += sFontFileName.substr(0, sFontFileName.length() - 4);
sFOTFile += ".FOT";
string source = sSourceDir;
string dest = sFontDir;
source += sFontFileName;
dest += sFontFileName;
//copy file
cout << source.c_str() << " " << dest.c_str() << endl;
cout << CopyFile(source.c_str(), dest.c_str(), FALSE) << endl;
cout << GetLastError() << endl;`
'CopyFile'(和'GetLastError')返回什么? (另外,我猜这是缺少权限) – Hasturkun
CopyFile返回1,GetLaseError值为0,我的权限是manager.the文件存在于C:\ Windows \ Fonts中,但它没有使用。没有名称,没有属性,一旦闪光,它不见了 –
我不认为它可能复制字体到字体文件夹没有安装字体第一。需要'CreateScalableFontResource'和'AddFontResource' APIs – SSpoke