Is there some Windows expert or someone you can tell me if I do
things wrong?
I can open the printer and also print but I'm failing to restore
the printer settings from a file.
```d
import core.sys.windows.windows;
import core.sys.windows.winspool;
import std;
pragma(lib, "winspool.lib");
extern (Windows) BOOL IsValidDevmodeA(PDEVMODEA pDevmode, size_t
DevmodeSize);
// ...
string path; // contains a valid path to a previously saved
printer properties struct file
char* cPrinterName; // just to simplify, it comes from toStringz
and contains the correct name
const(ubyte)[] pDevModeInputBuf = cast(ubyte[]) read(path); //
reads 1689 bytes
DEVMODEA* initData = cast(DEVMODEA*) pDevModeInputBuf.ptr;
HANDLE pHandle;
OpenPrinterA(cPrinterName, &pHandle, null); // success, pHandle
points to something
// returns the bytes needed for the printer properties
long docRs = DocumentPropertiesA(null, pHandle, cPrinterName,
null, null, 0); // 1689 bytes, so also correct
// everyting correct:
// initData.dmDeviceName == cPrinterName
// initData.dmSize + initData.dmDriverExtra == docRs, 1689 bytes
IsValidDevmodeA(initData, docRs); // true
// just to be sure
SetLastError(0); // GetLastError() is 0
// and now this fails:
uint flags = DM_IN_BUFFER;
docRs = DocumentPropertiesA(null, pHandle, cPrinterName, null,
initData, flags);
// docRs is -1
// GetLastError() is 131
// 131 = ERROR_NEGATIVE_SEEK
```
Negative seek? This is file related - what's going on here?