Re: This does not work on XP
- Posted by Brian Broker <brian_broker at yahoo.com> Jan 08, 2006
- 524 views
Rod Damon wrote: > > The following routine works just fine on WIN98 but bombs on my XP. WHY? > I can program Euphoria just fine, but not API. > Can someone with API programming knowlege help me. > This is part of my windows printing package that I posted awhile back. > Now I know why there have been some complaints on the forum. > > Any help would be appreciated. Thanks in advance. > > }}} <eucode> > -- print.ew -- > --originally by Jacques Deschenes, api_wrap.zip > > include machine.e > include dll.e > > -- ** added from win_misc.ew > function peeksz(atom pStr) -- peek string zero > -- return from allocated memory a string terminated by zero > integer c,i > sequence str > str = {} > i = 1 > c = peek(pStr) > while c do > str = str & c > c = peek(pStr+i) > i = i + 1 > end while > return str > end function > > constant > iEnumPrinters = define_c_func(winspool,"EnumPrintersA",{C_INT,C_INT,C_INT, > C_INT,C_INT,C_INT,C_INT},C_INT) > > constant > PRINTER_ENUM_DEFAULT = 1 > > global function DefaultPrinterName() > -- return default printer name > atom pPInfo5, pNeeded, pReturned, ok, needed > sequence PrinterName > > pNeeded = allocate(4) mem_set(pNeeded,0,4) > pReturned = allocate(4) mem_set(pReturned,0,4) > -- first try to know how many bytes needed for pPInfo5 > ok = > c_func(iEnumPrinters,{PRINTER_ENUM_DEFAULT,NULL,5,0,0,pNeeded,pReturned}) > needed = peek4u(pNeeded) > pPInfo5 = allocate(needed) mem_set(pPInfo5,0,needed) > ok = c_func(iEnumPrinters,{PRINTER_ENUM_DEFAULT,NULL,5,pPInfo5,needed, > pNeeded,pReturned}) > free(pNeeded) > free(pReturned) > if not ok then > free(pPInfo5) > return {} > else > PrinterName = peeksz(peek4u(pPInfo5)) > free(pPInfo5) > return PrinterName > end if > end function > > Rod Damon For a guy like me, it's easier to debug when you give as many details as you can. Do I need api_wrap.zip? I get: winspool has not been declared iEnumPrinters = define_c_func(winspool,"EnumPrintersA",{C_INT,C_INT,C_INT, ^ All I can say is that you need to declare 'winspool'.... -- Brian