CreateFont / DeleteObject leaves font file locked on application exit

  • Thread starter Thread starter Peter Dell - JAC
  • Start date Start date
P

Peter Dell - JAC

Guest
Hello,

I use the CreateFont/DeleteObject functions to load/create and release a custom font in my Win32 Application as follows:


hFont = CreateFont(fontHeight, 0, 0, 0, 0, 0, 0, 0, OEM_CHARSET, 0, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FIXED_PITCH, szFontName);
...
if (hFont != NULL) {

BOOL bResult = DeleteObject(hFont);

hFont = NULL;

if (!bResult) {

throw new std::runtime_error("Cannot delete font");

}

}


The DeleteObject correctly returns "1 = success", but even after the WinMain() of the application has ended and the application is terminated, the font file (in a subdirectory besides the .exe) remains locked and causes problem when the next build tries to overwrite it.

Do you have any ideas why or what I could do differently to fix this?

Best regards, Peter.


Continue reading...
 
Back
Top