|
HRESULT RegFont(PTSTR tzPath)
{
WIN32_FIND_DATA fd;
TCHAR szFullPathName[MAX_PATH];
HRESULT hResult=ERROR_FILE_NOT_FOUND;
HANDLE hFind = FindFirstFile(tzPath, &fd);
UDirSplitPath(tzPath);
if (hFind != INVALID_HANDLE_VALUE)
{
do
{
if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY)
{
UStrPrint(szFullPathName, TEXT("%s\\%s"), tzPath,fd.cFileName);
AddFontResource(szFullPathName);
}
}
while (FindNextFile(hFind,&fd));
FindClose(hFind);
hResult = (HRESULT) SendMessage(HWND_BROADCAST,WM_FONTCHANGE, 0, 0);
}
return hResult;
}
///////////////////////////////////////////////////////////
//REG FONT
HRESULT Font(PTSTR ptzCmd)
{
TCHAR tzPath[MAX_NAME];
HRESULT hResult=ERROR_FILE_NOT_FOUND;
if (ptzCmd[0] == '\\')
{
ptzCmd++;
TCHAR tzDrives[MAX_NAME];
GetLogicalDriveStrings(MAX_NAME, tzDrives);
for (PTSTR p = tzDrives; *p; p += UStrLen(p) + 1)
{
UStrPrint(tzPath, TEXT("%s%s\\Fonts"), p, ptzCmd);
if (UDirExist(tzPath))
{
UStrCat(tzPath, TEXT("\\*.*"));
hResult = RegFont(tzPath);
}
}
}
else
{
if (UDirExist(ptzCmd)) UStrCat(ptzCmd, TEXT("\\*.*"));
UStrPrint(tzPath,TEXT("%s"),ptzCmd);
UDirSplitPath(ptzCmd);
if (UDirExist(ptzCmd))
{
hResult = RegFont(tzPath);
}
}
return hResult;
}
[ 本帖最后由 lxl1638 于 2007-1-27 11:27 PM 编辑 ] |
|