Archive: Registering fonts with Windows...


Registering fonts with Windows...
Hey there,

I need to register some fonts distributed along with my program.

The problem is that the registry key where the font strings are located differs between Win NT based Windows versions and Win9x based Windows versions.

I searched the archive to find a solution and found a tutorial on how to retrieve the current Windows version.

Well that's fine, but I would need to write syntax like:
if( version == win_nt ) { do this; }
else { do that; }

AFAIK there IS no equivalent to the if-statement in NSIS scripting language, so how can I switch a statement?


There is.

Example:

ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion

StrCmp $R0 "" 0 winnt

...code for Windows 9x...

Goto done

winnt:

...code for Windows NT...

done:


Another topic about registering fonts (with a plug-in): http://forums.winamp.com/showthread.php?threadid=79586

Instead of the plug-in you can use this code to register fonts:

!include WinMessages.nsh

System::Call "GDI32::AddFontResourceA(t) i ('fontname.fon') .s"
Pop $0
# $0 is zero if the function failed
SendMessage ${HWND_BROADCAST} ${WM_FONTCHANGE} 0 0


and to remove:
!include WinMessages.nsh

System::Call "GDI32::RemoveFontResourceA(t) i ('fontname.fon') .s"
Pop $0
# $0 is zero if the function failed
SendMessage ${HWND_BROADCAST} ${WM_FONTCHANGE} 0 0

Hi Matt
I'm guessing that's the D-Day Matthias?


-Stu :)


Thanks for your replies.

Hi Matt
I'm guessing that's the D-Day Matthias?
Sorry, no. I'm probably just another Matthias :)

Originally posted by matthias_k
Thanks for your replies.


Sorry, no. I'm probably just another Matthias :)
Woh cool.
I just referred another Matthias to NSIS and I thought he was you - he's around here somewhere :)

Good luck with NSIS!

NSIS rocks!

I'm drunk :)

-Stu

NSIS rocks!
Hell yeah it does! The best installer I've seen so far.

Kudos to the guys from NullSoft.