问题
I have a program which uses winapi functions. When it runs on WinXP (32bit) or Win7 (64bit) everything is OK. But on Win8 (64bit) there is a bug: sometimes program hangs on this code line
HDC hDisplay = CreateDC("DISPLAY", NULL, NULL, NULL);
What might be the reason of it?
p.s. It is built in MSVC 2005 on WinXP 32 bit for platform Win32.
回答1:
Try:
CreateDC(TEXT("DISPLAY"),NULL,NULL,NULL)
回答2:
I have managed to rebuild program for 64bit platform, and it works now.
回答3:
While this question is very old, we're encountering a similar issue today.
We have code that is attempting to Query Printers in this Manner:
hdc = CreateDC(pi->pDriverName, pi->pPrinterName, pi->pPortName, NULL);
Where pi
is a PRINTER_INFO_2
structure (https://docs.microsoft.com/en-us/windows/win32/printdocs/printer-info-2).
It seems like after installing Microsoft KB4517298 (https://support.microsoft.com/en-us/help/4517298/windows-8-1-update-kb4517298) on our Server 2012R2 boxes this line hangs for no apparent reason. Rebuilding the Application in 64bits appears to fix it as it did for the original poster. However we're still at a loss as to why this occurs. Removing the hotfix resolves the issue and reapplying it causes it again.
We're working with our vendor to see if we can get some type of visibility as to why this recent Windows Update broke us (and even better how to fix it!).
来源:https://stackoverflow.com/questions/17312657/winapi-createdc-hangs-on-win-8