我想在我的系統中安裝一種新的字體,但是在我的代碼中出現錯誤,我找不到我犯的錯誤。在我調用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