I get
error wrote:
---------------------------
test-script4.ahk
---------------------------
Error in #include file ...\Tests\SGDIPrint\Lib\SGDIPrint.ahk":
This DllCall requires a prior VarSetCapacity. The program is now unstable and will exit.
Line#
115: WinGet,MainhWnd,ID,ahk_pid %mainPID%
116: DetectHiddenWindows,%T_DetectHiddenWindows%
117: NULL := ""
119: VarSetCapacity(pPrinter , A_PtrSize, 0)
120: out := DllCall("Winspool.drv\OpenPrinter", "Ptr", &pPrinterName, "PtrP", pPrinter, "UInt", NULL, "Ptr")
122: sizeDevMode := DllCall("Winspool.drv\DocumentProperties", "Ptr", MainhWnd, "Ptr", pPrinter, "StrP", pPrinterName, "Ptr", &pDevModeOutput, "Ptr", &pDevModeInput, "UInt", 0)
124: VarSetCapacity(pDevModeOutput , sizeDevMode, 0)
---> 125: out2 := DllCall("Winspool.drv\DocumentProperties", "Ptr", MainhWnd, "Ptr", pPrinter, "StrP", pPrinterName, "Ptr", &pDevModeOutput, "Ptr", &pDevModeInput, "UInt", 2)
127: if ((dmOrientation = 1)||(dmOrientation = 2))
128: NumPut(dmOrientation, pDevModeOutput, 44, "Short")
129: if dmCopies is integer
130: {
131: if (dmCopies > 0)
132: NumPut(dmCopies, pDevModeOutput, 54, "Short")
133: }
The current thread will exit.
---------------------------
OK
---------------------------
By the way, I just noticed,
Zed Gecko wrote:
Code:
...
out := DllCall("Winspool.drv\EnumPrinters", "UInt", PRINTER_ENUM_NAME, "Str", NULL, "UInt", Level, "Ptr", 0, "UInt", 0, "UIntP", pcbNeeded, "UIntP", pcReturned)
pcbGranted := VarSetCapacity(pPrinterEnum , pcbNeeded)
out := DllCall("Winspool.drv\EnumPrinters", "UInt", PRINTER_ENUM_NAME, "Str", NULL, "UInt", Level, "Ptr", &pPrinterEnum, "UInt", pcbGranted, "UIntP", pcbNeeded, "UIntP", pcReturned)
msdn wrote:
BOOL EnumPrinters(
__in DWORD Flags,
__in LPTSTR Name,
__in DWORD Level,
__out LPBYTE pPrinterEnum,
__in DWORD cbBuf,
__out LPDWORD pcbNeeded,
__out LPDWORD pcReturned
);
pcbNeeded [out]
A pointer to a value that receives the number of bytes copied if the function succeeds or the number of bytes required if cbBuf is too small.
pcReturned [out]
A pointer to a value that receives the number of PRINTER_INFO_1, PRINTER_INFO_2 , PRINTER_INFO_4, or PRINTER_INFO_5 structures that the function returns in the array to which pPrinterEnum points.
So, the types for the last two parameters of EnumPrinters should be ptrp.