Vista's security features have got me stumped. I'm hoping that someone can point me in the right direction.
Our application uses a non-proportional raster font (Raize.fon) that is not installed with Windows. Hoping to avoid having to manually install this font on every workstation which uses our application, I have attempted to add code to install the font programmatically. The technique which I used was to detect the user's font folder, to copy the font to it using the COPY FILE command and then to use the Microsoft utility program FONTINST.EXE to "register" the font. And, in fact, this works fine on XP machines.
With Vista, however, this procedure fails. I am logged in as a user in the Administrators group. If User Account Control is turned off, the copy operation is apparently successful, but in a strange way. If you use the VFP DIR command to review the contents of the C:\Windows\Fonts folder, the font is there. But if you use Windows Explorer to view the contents of the C:\Windows\Fonts folder, the font is not there! And although no error occurs, the font is not available to VFP after running FONTINST. If User Account Control is turned on, the copy operation fails with a permission error.
Is it possible to install fonts programmatically in Vista?
-- Jim Vahl
Although I haven't tested this with fonts, this is likely related to Vista security in general. Even when you're logged in as an administrator, you do not have administrative privileges on the system; see http://advisor.com/doc/18897 for details. In order to install something in a protected folder, you need to run elevated. Since you really don't want to run your app in an elevated mode (that opens security holes), you have two choices: install the font during installation, since the installer forces the user to elevate, or have your app run another EXE as an elevated process to just do font installation (see http://doughennig.blogspot.com/2007/04/elevating-tasks-in-vista.html for details).
-- Doug Hennig
Doug, a belated thank you for your answer! The issue is indeed related to Vista security. The solution was to abandon the FONTINST approach and instead use code based on the Fox KB article for True-Type fonts http://support.microsoft.com/kb/186722 . Because the font is not True Type, we removed the code related to the CreateScalableFontResource method and placed the font file name directly into the AddFontResource method. We call this modified program from our application's initialzation routine if the font is not installed as detected by AFONT(). The user must run the application EXE "As Administrator" one time in order for the font to install correctly in Vista. Thereafter elevation is not necessary.
FYI, there are some very peculiar behaviors with the Fonts folder under Vista. We have had our font installed and active, but not appearing in the Fonts folder. We have copied the font programmatically to the Fonts folder where it appears if you use the VFP DIR command or if you run CMD from Vista, but it does not appear in Windows Explorer nor in the Fonts display under Control Panel. However, if you choose to install a new font and point the file picker to the Fonts folder, there it is, and you can install it!
-- Jim Vahl
( Topic last updated: 2008.04.03 04:58:35 PM )