![]() |
| ||
| Need help with AddFontResource Hey, it's me again. This time with a thing that has been bugging me for months and i still haven't gotten around to solving it. I need to install a font without rebooting the computer. Sounds simple but i have to do it in code or with a batch file, popping windows in front of the user isn't an option. I've done a lot of trials on batch files and that fontinst.exe crap, nothing worked. Somehow i stumbled upon the MSDN documentation of AddFontResource() which sounds like the thing for me. I understand i also have to use SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0) at the end so the fonts are refreshed in all windows. I chose to do it in C++ because i also learn it at school (i'm in 11th grade). What we learn is the old Borland stuff but still it is of some use. Anyway, i really need to wrap up all those batches and javascripts i wrote in one single program with as little dependencies as possible, and C++ seems to be the best choice. I'm currently using Dev-C++ 5 beta. #include <cstdlib> I wrote that just to test the function. The problem with the above code is that... It does nothing. :-O It compiles and runs, but the font is still not registered to the system until i reboot. Prior to running this program the font is copied to the Windows\Fonts folder and the necessary registry entries are created, via a batch file. I need some explanation on the LPCTSTR thing. What the heck is it exactly? It seems it's not a string as it doesn't take the name stored in "myfont". The MSDN entry is very very vague. Quote:
|
| ||
| Re: Need help with AddFontResource I'm a newbie, so i make newbie mistakes. I didn't understand Microsoft's notations and thought LPCTSTR was a parameter, while it was actually the LPCTSTR datatype. I got it solved like this: #include <cstdlib> And adding -lgdi32 to the Dev-Cpp linker's parameters. Damn, it was that simple. Off to make it read the font name from an INI file and wrap up the rest of the batches. ;) |
| ||
| Re: Need help with AddFontResource But if char array is all you have, and you're not compiling with UNICODE, then this (it would seem) would work just as well AddFontResource(filename); |
| ||
| Re: Need help with AddFontResource I might need Unicode sometime, i'll just leave it as it is for now. I set it to read from an INI file, now i'm off to finish the rest of the code. Thanks, and you can be sure i'll be back if i run into trouble again. :) |
| All times are GMT -4. The time now is 7:17 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC