Is there some other call that I've missed that does the same thing?
Perhaps have you no printers connected or with power on.
Perhaps give you bad parameters to the function.
can you post the call to the function ?
This is just a guess, but your source must include winspool.inc and winspool.lib.
This is what I have now, when I try to assemble it the assembler states that EnumPrinters is undefined. Will check on the winspool files.........
.486 ; create 32 bit code
.model flat, stdcall ; 32 bit memory model
option casemap :none ; case sensitive
include \masm32\include\windows.inc
include \masm32\include\masm32.inc
include \masm32\include\gdi32.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\Comctl32.inc
include \masm32\include\comdlg32.inc
include \masm32\include\shell32.inc
include \masm32\include\oleaut32.inc
include \masm32\include\msvcrt.inc
includelib \masm32\lib\masm32.lib
includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\Comctl32.lib
includelib \masm32\lib\comdlg32.lib
includelib \masm32\lib\shell32.lib
includelib \masm32\lib\oleaut32.lib
includelib \masm32\lib\msvcrt.lib
.data?
EnumStructure db 1024 DUP (?)
Bytescopied dd ?
numPrinters dd ?
.data
Flags dd PRINTER_ENUM_LOCAL
pName dd NULL
Level dd 2
pEnum dd OFFSET EnumStructure
cbBuf dd 1024
Needed dd OFFSET Bytescopied
Retrned dd OFFSET numPrinters
Capt db "Debug Messagebox",NULL
mFalse db "Didn't work",NULL
mTrue db "Worked",NULL
.code
start:
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
invoke EnumPrinters,Flags,pName,Level,pEnum,cbBuf,Needed,Retrned
cmp al,TRUE
jz worked
invoke MessageBox,0,addr mFalse,addr Capt,MB_OK
invoke ExitProcess,NULL
worked:
invoke MessageBox,0,addr mTrue,addr Capt,MB_OK
invoke ExitProcess,NULL
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start
Quote from: MichaelW on December 20, 2007, 10:37:49 PM
This is just a guess, but your source must include winspool.inc and winspool.lib.
That's what is was, sure enough
On most systems EnumPrinters will enumerate more than one printer, even if the system has only one physical printer attached. For example, on my system it enumerates two:
HP DeskJet 1000C,HP DeskJet 1000C
Fax,Windows NT Fax Driver
Since you have no reasonably way to know how many printers will be enumerated, or how big the returned data for each printer will be, Microsoft provided a method of determining the size of the required buffer. To do this you first call the function with the cbBuf parameter set to zero, then use the value returned in cbNeeded to size the buffer. On return from a successful second call the buffer will include, for each printer, the PRINTER_INFO_x structure (all of which are defined in the MASM32 windows.inc), and then following the last structure any associated strings (and possibly other data).