Error creating window when Data Execution Prevention is on

58 Views Asked by At

In an old C++ application, an error will occur at the last line below when Data Execution Prevention is enabled:

IPrintDlg *pPrintdlg = NULL;
CLSID clsidPrintDlg;
HRESULT hResult = ::CLSIDFromProgID(OLESTR("MyCompany.PrintDlg"), &clsidPrintDlg);
if (SUCCEEDED(hResult))
    hResult = ::CoCreateInstance(clsidPrintDlg, NULL, CLSCTX_INPROC_SERVER, IID_IPrintDlg, (LPVOID*) &pPrintDlg);
HRESULT hr = pPrintDlg->Create((long)GetSafeHwnd());

IPrintDlg is an interface to a separate C++ component that displays a printer dialog, and it implements IDispatch. The error has Event ID: 1000.

The client does not want to turn DEP off so I'm trying to find a way to fix the code so it does not violate the DEP restriction. Any ideas?

0

There are 0 best solutions below