Skip to content

Instantly share code, notes, and snippets.

@Donpedro13
Last active October 26, 2020 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Donpedro13/16e0bf7ad542967158b086fca01d9e41 to your computer and use it in GitHub Desktop.
Save Donpedro13/16e0bf7ad542967158b086fca01d9e41 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <windows.h>
#include <wingdi.h>
int main ()
{
PRINTDLGW dialogResult = {};
dialogResult.lStructSize = sizeof dialogResult;
dialogResult.Flags = PD_RETURNDEFAULT;
PrintDlgW (&dialogResult);
DEVMODEW* pDefaultDevMode =
(DEVMODEW*)GlobalLock (dialogResult.hDevMode);
unsigned char* pDriverPrivateData =
(unsigned char*)pDefaultDevMode + sizeof (DEVMODEW);
// Magic offsets...
for (size_t i = 3290; i < 3300; ++i)
pDriverPrivateData[i] = 0;
HDC hDC = CreateICW (L"winspool",
pDefaultDevMode->dmDeviceName,
L"LPT1:",
pDefaultDevMode);
std::cout << "CreateICW " <<
(hDC ? "succeeded!" : "failed!") << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment