Got a lot of the bugs out of My Prog. It is now giving this message in WM_Create
using GetLastError code: "data area passed to a system call is to small".
The EnumPrinter has the cbBuf set to zero.
I tried to use "dwtoa" to find out what was in the pcbNeeded parameter
but it did not execute. I obviously have some [] or addr incorrect.
The DWTOA code is by WJR.
.data
dwNeeded dd 0
dwReturned dd 0
TM18 db 'dwNeeded',0
convfld db ' ',0
.code
; other goodies
WndProc:
FRAME hWnd,iMsg,wParam,lParam
USES ebx,edi,esi
Local hdc,hdcPrn
;.WM_CREATE
cmp D[iMsg],WM_CREATE
jne >>.WM_CHAR
invoke EnumPrintersA, PRINTER_ENUM_LOCAL,NULL,4,NULL,0,\
[dwNeeded],[dwReturned]
; test begin
; edx is the input field
; ebx convfld is the output field
pushad
mov edx, [dwNeeded]
mov ebx, addr convfld
mov [BufAdd],ebx
invoke dwtoa, edx, [BufAdd] ; Hex DD to string
invoke MessageBox, NULL,[TM18],[convfld], MB_OK
popad
; test end
jmp >>.default
; other goodies
;code per WJR
dwtoa:
FRAME dwValue,lpBuffer
USES esi,edi
; -------------------------------------------------------------
; convert DWORD to ascii string
; dwValue is value to be converted
; lpBuffer is the address of the receiving buffer
; EXAMPLE:
; invoke dwtoa,edx,addr buffer
;
; Uses: eax, ecx, edx.
; -------------------------------------------------------------
mov eax,[dwValue]
mov edi,[lpBuffer]
test eax, eax ; is the value negative
jns >
mov B[edi], '-' ; store a minus sign
inc edi
neg eax ; and invert the value
:
mov esi, edi ; save pointer to first digit
mov ecx, 10
.convert
test eax,eax ; while there is more to convert
jz >
xor edx, edx
div ecx ; put next digit in edx
add dl, '0' ; convert to ASCII
mov [edi],dl ; store it
inc edi
jmp <.convert
:
mov B[edi], 0 ; terminate the string
.reverse ; We now have all the digits,
; but in reverse order.
cmp esi,edi
jae >
dec edi
mov al,[esi]
mov ah,[edi]
mov [edi],al
mov [esi],ah
inc esi
jmp <.reverse
:
ret
endf