Hi Satpro,
Thank you for replying.
Don't misunderstand me I am not blaming GoAsm for my inadequacies.
I have incorporated your suggestions and still no luck as you can see below.
I don't use macros either as I hate to dig all over the place to find out what
they need or mean. Same with includes. Only when necessary.
The next 3 lines are a quote from the Microsoft CreateDC API.
lpszDriver
"A pointer to a null-terminated character string that specifies either DISPLAY or the name
of a specific display device. For printing, we recommend that you pass NULL to lpszDriver
because GDI ignores lpszDriver for printer devices".
Enumprinter 2 puts garbage in parmeter 4 which is PrinterCString.
Therefor CreatDC does not work.
.data
dwNeeded dd 0
dwReturned dd 0
PrintCString db 96 DUP 0 ; buffer to receive the printer name
winspoolstring db "WINSPOOL",0
.code
; other code
WndProc:
FRAME hWnd,iMsg,wParam,lParam
USES ebx,edi,esi
Local hMemory,hdc,hdcPrn
;.WM_CREATE
cmp D[iMsg],WM_CREATE
jne >>.WM_CHAR
invoke EnumPrinters, PRINTER_ENUM_LOCAL,NULL,4,NULL,\
0,addr dwNeeded,addr dwReturned
invoke GlobalAlloc, GHND,[dwNeeded]
mov [hMemory], eax
invoke GlobalLock, eax
invoke EnumPrinters, PRINTER_ENUM_LOCAL,NULL,4,addr PrintCString,\
[dwNeeded],addr dwNeeded,addr dwReturned
; test begin
;tm2 db 'got to WM_CREATE',0
pushad
invoke MessageBox, NULL,addr TM2,addr PrintCString,MB_OK
popad
; test end
;The result of this test shows "yo@" with a tilder over the "o" in PrintCString.
;So good data is not getting into PrintCSring even though EnumPrinter is not
; failing. Of course this causes CreatDC to also fail.
mov ebx,addr PrintCString
invoke CreateDC, addr winspoolstring,[ebx+PRINTER_INFO_4.pPrinterName],NULL,NULL
mov [hdcPrn],eax
invoke GlobalUnlock, [hMemory]
invoke GlobalFree, [hMemory]
endf