
Is it possible to use InstallShield Professional 5 to install fonts with an installation?
My program requires a certain font, and I would like to be able to install one along with it.
Thanks,

Brian
Posted 29 July 2003 - 17:40
Posted 29 July 2003 - 20:00
Stefan Krüger
InstallSite.org twitter facebook
Posted 29 July 2003 - 20:15
CODE |
STRING szFileTTF, sfFileFot, svResult, svFontFile,svFontDir, svFontBackup, svFontName; STRING svttfFile, svfotFile, szKey, szInfo,svValue; NUMBER nResult, nvType, nvSize,nvResult; BOOL bReplace, bWin16,bWin31, bWin95, bWin98, bWinNt,bWin351; STRING svLogFile; INT NVResult; #define HWND_BROADCAST 0xFFFF #define WM_FONTCHANGE 0x001D prototype INT GDI32.AddFontResource(BYREF STRING); program if (GetSystemInfo (OS, nvResult, svResult) < 0) then szInfo = "Couldn't get Operating System info."; else switch (nvResult) case IS_WINDOWS: szInfo = "OS: Windows 3.1"; bWin31 = TRUE; case IS_WINDOWSNT: GetSystemInfo ( OSMAJOR , nvResult , svResult ); if (nvResult < 4) then bWin351 = TRUE; else bWinNt = TRUE; endif; szInfo = "OS: Windows NT"; case IS_WINDOWS9X: GetSystemInfo (WINMINOR, nvResult, svResult); if (nvResult < 10) then szInfo = "OS: Windows 95"; bWin95 = TRUE; else szInfo = "OS: Windows 98"; bWin98 = TRUE; endif; endswitch; endif; //Set up uninstall TARGETDIR = WINDIR^"TEMP"; InstallationInfo("FONT COMPANY", "FONT INSTALLER", "1.0", "arlrdbd.fot"); DeinstallStart(TARGETDIR, svLogFile, "UNINSTALL KEY" ,0); RegDBSetItem(REGDB_UNINSTALL_NAME, "Font Installer"); //Do Font Installation svfotFile = "ARLRDBD.FOT"; svttfFile = "ARLRDBD.TTF"; szKey = "SOFTWARE\MICROSOFT\WINDOWS"; if((bWinNt)|| (bWin351)) then szKey = szKey+ " NT"; endif; szKey = szKey +"\CurrentVersion\Fonts"; nvType =REGDB_STRING; RegDBSetDefaultRoot ( HKEY_LOCAL_MACHINE ); RegDBGetKeyValueEx ( szKey , "Arial Rounded MT Bold (TrueType)" , nvType , svValue , nvSize ); if (svValue != svttfFile) then MessageBox ( "Font does not exist, ready to add" , INFORMATION ); if (bWinNt || bWin95 || bWin98)then svFontDir = WINDIR^"Fonts"; elseif (bWin351) then svFontDir = WINSYSDIR; endif; TARGETDIR=svFontDir; svFontFile = svFontDir^svttfFile; svFontBackup= svFontDir^svttfFile; nResult = FindFile(svFontDir, "Arlrdbd.ttf", svResult); bReplace = FALSE; if (nResult = 0) then nResult = AskYesNo("The File" + svttfFile + "was found in the windows font"+ " folder. Do you want to replace it?"+ "(If you answer NO the installation will use this as the font.)", NO); if (nResult=YES) then VarSave(SRCTARGETDIR); SRCDIR=TARGETDIR; DeleteFile("ARLRDBD.BAK"); RenameFile("ARLRDBD.TTF", "ARLRDBD.BAK"); VarRestore(SRCTARGETDIR); endif; endif; nResult = CopyFile(svttfFile, svttfFile); if (nResult < 0) then MessageBox("CopyFile function failed", INFORMATION); endif; MessageBox(" the font file is " + svttfFile, INFORMATION); RegDBSetKeyValueEx ( szKey , "Arial Rounded MT Bold TrueType" , REGDB_STRING , svFontFile , -1 ); nResult = AddFontResource(svFontFile); SendMessage(HWND_BROADCAST,WM_FONTCHANGE,0,0); if (nResult !=0) then MessageBox ( "The Font was added successfully." , INFORMATION ); else MessageBox("The Font Already Exists", INFORMATION); endif; endif; endprogram |
Edited by briglass, 29 July 2003 - 20:17.