Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Add/RemoveFontResource()

59 views
Skip to first unread message

Phil Da Lick!

unread,
Aug 10, 2010, 8:35:21 AM8/10/10
to
Hi all,

Got a private font I'm adding with AddFontResource(fontname, FR_PRIVATE,
NULL) and removing with RemoveFontResource(fontname, FR_PRIVATE, NULL).

The font is being added and removed no problems. What I want to do is
remove the directory the font file is in (a temp folder) directly after
the RemoveFontResource() call. At this point the directory is empty but
the RemoveDirectory call is failing. GetLastError() is reporting that
the dir is in use by another app. This is not true. When the app exits I
can delete the folder in explorer without issue.

I've stripped the functionality of my app down to the point where all
that happens is the following:

create temp folder
copy the TTF into it
call CreateScalableFontResource()
//AddFontResource()
//RemoveFontResource()
delete the FOT file
delete the TTF file
RemoveDirectory()

If I comment as shown above the mechanism works perfectly. If I
uncomment the lines as shown (without actually doing anything else with
the font or the directory) then the RemoveDirectory() call fails.

Is this an optimisation issue on the GDI? Is it retaining some lock on
the folder?

Win XP, VS2008 pro.

Any ideas welcome!

P.

Dee Earley

unread,
Aug 10, 2010, 8:55:13 AM8/10/10
to
On 10/08/2010 13:35, Phil Da Lick! wrote:
> Hi all,
>
> Got a private font I'm adding with AddFontResource(fontname, FR_PRIVATE,
> NULL) and removing with RemoveFontResource(fontname, FR_PRIVATE, NULL).
>
> The font is being added and removed no problems. What I want to do is
> remove the directory the font file is in (a temp folder) directly after
> the RemoveFontResource() call. At this point the directory is empty but
> the RemoveDirectory call is failing. GetLastError() is reporting that
> the dir is in use by another app. This is not true. When the app exits I
> can delete the folder in explorer without issue.

It is true, you just aren't aware of it.
You can use Process Explorer to confirm what has the folder open.
I have no idea what you need to do to close it though.

--
Dee Earley (dee.e...@icode.co.uk)
i-Catcher Development Team

iCode Systems

(Replies direct to my email address will be ignored.
Please reply to the group.)

Phil Da Lick!

unread,
Aug 10, 2010, 11:04:11 AM8/10/10
to
On 10/08/2010 13:55, Dee Earley wrote:
> On 10/08/2010 13:35, Phil Da Lick! wrote:
>> Hi all,
>>
>> Got a private font I'm adding with AddFontResource(fontname, FR_PRIVATE,
>> NULL) and removing with RemoveFontResource(fontname, FR_PRIVATE, NULL).
>>
>> The font is being added and removed no problems. What I want to do is
>> remove the directory the font file is in (a temp folder) directly after
>> the RemoveFontResource() call. At this point the directory is empty but
>> the RemoveDirectory call is failing. GetLastError() is reporting that
>> the dir is in use by another app. This is not true. When the app exits I
>> can delete the folder in explorer without issue.
>
> It is true, you just aren't aware of it.

The sneaky little barsteward. Good call.


> You can use Process Explorer to confirm what has the folder open.
> I have no idea what you need to do to close it though.

Nor would I have without that app. Thanks for the recommendation.
Tracked something the other end of my program that I would never have
suspected otherwise. That's going straight in the "essentials" folder.

P.

0 new messages