AddFontResource - help

J

Jim

Hi,

I'm a total C++ neophyte, and we've got a short deadline to turn around.
Essentially, I need a utility that installs a series of fonts on a given
system, and I don't know whether the .NET runtime is installed on that
system, so I want something that will run w/o the .NET runtime, VB dlls,
etc. I know that I need to use AddFontResource, then WriteProfileString,
followed by doing a SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0&). I'm
using VC++ in Visual Studio .NET 2.0. However, I'm having a very hard time
with LPCTSTR and making this whole thing work.

Here is my code:
LPSTR fontPath = "C:\\ZQMRS___.pfm|C:\\ZQMRS___.PFB";
int fontCount = AddFontResource((LPCTSTR)fontPath);
WriteProfileString((LPCWSTR)"Fonts", (LPCWSTR)"Adobe Myriad Pro",
(LPCWSTR)fontPath);
SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);


This is probably totally wrong, but it's the best I've come up with so far.
Anyway, fontCount always is returned as 0 (zero) from the AddFontResource
call, so it's failing, but there is no error message available. Note that
these are PFM files, so we do have to include all associated files using the
| character.

Does anybody have any ideas or samples of how this can be done?

Thanks very much in advance!

Jim
 
J

Jim

We found a much easier way: use a self-extracting zip file, then run a batch
file at the end that copies the fonts to the font folder and then opens an
Explorer window to the Fonts folder.

This didn't seem like a big deal for somebody who is pretty C++ savvy, yet
there were no responses on this. Was I wrong?

Jim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top