Sintax de EnumJobs

Sintax de EnumJobs

Postby SENUN » Tue Nov 01, 2011 2:18 pm

Preciso obter o Status da impressão com a rotina abaixo.

não consigo faze-la funcionar.

alguem pode me ajudar ?

Grato,

#include "fivewin.ch"
#include "StrucT.ch"

#define PRINTER_ACCESS_ADMINISTER 0x00000004

STRUCT oPrnDefaults
MEMBER pDatatype AS LPSTR
MEMBER pDevMode AS LPSTR // LPDEVMODE
MEMBER DesiredAccess AS DWORD // ACCESS_MASK

MEMBER pFirstJob AS DWORD
MEMBER pNoJobs AS DWORD
MEMBER pLevel AS DWORD
MEMBER pJob AS DWORD // LPBYTE
MEMBER pcbBuf AS DWORD
MEMBER pcbNeeded AS DWORD // LPDWORD
MEMBER pcReturned AS DWORD //BOOL // LPDWORD

ENDSTRUCT


oPrnDefaults:DesiredAccess = PRINTER_ACCESS_ADMINISTER

If OpenPrinter(cPrinter , @hDC , oPrnDefaults:cBuffer )
If hDC # 0
oPrnDefaults:pFirstJob :=0
oPrnDefaults:pNoJobs :=100
oPrnDefaults:pLevel :=1
oPrnDefaults:pcbBuf :=0

********************************************************************
Result = EnumJobs(cPrinter, oPrnDefaults:pFirstJob ,;
oPrnDefaults:pNoJobs ,;
oPrnDefaults:pLevel ,;
oPrnDefaults:pJob ,;
oPrnDefaults:pcbBuf ,;
oPrnDefaults:pcbNeeded ,;
oPrnDefaults:pcReturned )

********************************************************************

msginfo( tostring( Result ) , "rESULT" )
msginfo( tostring(oPrnDefaults:pFirstJob ) , "Abrindo oPrnDefaults:pFirstJob " )
msginfo( tostring(oPrnDefaults:pNoJobs ) , "Abrindo oPrnDefaults:pNoJobs " )
msginfo( tostring(oPrnDefaults:pLevel ) , "Abrindo oPrnDefaults:pLevel " )
msginfo( tostring(oPrnDefaults:pJob ) , "Abrindo oPrnDefaults:pJob " )
msginfo( tostring(oPrnDefaults:pcbBuf ) , "Abrindo oPrnDefaults:pcbBuf " )
msginfo( tostring(oPrnDefaults:pcbNeeded ) , "Abrindo oPrnDefaults:pcbNeeded " )
msginfo( tostring(oPrnDefaults:pcReturned ) , "Abrindo oPrnDefaults:pcReturned " )

ClosePrinter( hDC )

else
// msginfo("não passando hDC # 0 " )
RETURN .F.
Endif
else
// msginfo("openprinter " )
RETURN .F.

Endif


//------------------------------------------------------------------------//

DLL32 FUNCTION OpenPrinter( pName AS LPSTR, @pPrinter AS LONG, pDef AS LPSTR ) ;
AS BOOL PASCAL ;
FROM "OpenPrinterA" LIB "winspool.drv"

//------------------------------------------------------------------------//
DLL32 FUNCTION EnumJobs( hPrinter AS LPSTR , FirstJob AS DWORD,;
NoJobs AS DWORD , Level AS DWORD,;
@pJob AS LPSTR , cbBuf AS DWORD,;
@pcbNeeded AS DWORD , @pcReturned AS DWORD ) ;
AS LONG PASCAL ;
FROM "EnumJobsA" LIB "winspool.drv"
//------------------------------------------------------------------------//

/*
BOOL EnumJobs(
__in HANDLE hPrinter,
__in DWORD FirstJob,
__in DWORD NoJobs,
__in DWORD Level,
__out LPBYTE pJob,
__in DWORD cbBuf,
__out LPDWORD pcbNeeded,
__out LPDWORD pcReturned
);
*/
Nelson Araujo
Email : nelson.n.araujo@gmail.com
nelson.n.araujo@terra.com.br

MSN : nelson.n.araujo@hotmail.com

Clipper 5.3 - FW 2.4 - BCC55
SENUN
 
Posts: 4
Joined: Thu Aug 11, 2011 9:00 pm

Re: Sintax de EnumJobs

Postby Antonio Linares » Tue Nov 08, 2011 1:44 am

Nelson,

Pruébalo de esta forma. Asi Result devuelve 1 que significa que funcionó bien :-)

Code: Select all  Expand view  RUN
#include "fivewin.ch"
#include "StrucT.ch"

#define PRINTER_ACCESS_ADMINISTER 0x00000004

#define tostring(x) cValToChar(x)

function Main()

   Test()

return nil

function Test()

   local oPrnDefaults, cPrinter := "Microsoft XPS Document Writer", hDC

STRUCT oPrnDefaults
MEMBER pDatatype AS LPSTR
MEMBER pDevMode AS LPSTR // LPDEVMODE
MEMBER DesiredAccess AS DWORD // ACCESS_MASK

MEMBER pFirstJob AS DWORD
MEMBER pNoJobs AS DWORD
MEMBER pLevel AS DWORD
MEMBER pJob AS DWORD // LPBYTE
MEMBER pcbBuf AS DWORD
MEMBER pcbNeeded AS DWORD // LPDWORD
MEMBER pcReturned AS DWORD //BOOL // LPDWORD

ENDSTRUCT


oPrnDefaults:DesiredAccess = PRINTER_ACCESS_ADMINISTER

If OpenPrinter(cPrinter , @hDC , oPrnDefaults:cBuffer )
If hDC # 0
oPrnDefaults:pFirstJob :=0
oPrnDefaults:pNoJobs :=100
oPrnDefaults:pLevel :=1
oPrnDefaults:pcbBuf :=0

********************************************************************
Result = EnumJobs( hDC, oPrnDefaults:pFirstJob ,;
                   oPrnDefaults:pNoJobs ,;
                   oPrnDefaults:pLevel ,;
                   oPrnDefaults:pJob ,;
                   oPrnDefaults:pcbBuf ,;
                   oPrnDefaults:pcbNeeded ,;
                   oPrnDefaults:pcReturned )

********************************************************************

msginfo( tostring( Result ) , "rESULT" )
msginfo( tostring(oPrnDefaults:pFirstJob ) , "Abrindo oPrnDefaults:pFirstJob " )
msginfo( tostring(oPrnDefaults:pNoJobs ) , "Abrindo oPrnDefaults:pNoJobs " )
msginfo( tostring(oPrnDefaults:pLevel ) , "Abrindo oPrnDefaults:pLevel " )
msginfo( tostring(oPrnDefaults:pJob ) , "Abrindo oPrnDefaults:pJob " )
msginfo( tostring(oPrnDefaults:pcbBuf ) , "Abrindo oPrnDefaults:pcbBuf " )
msginfo( tostring(oPrnDefaults:pcbNeeded ) , "Abrindo oPrnDefaults:pcbNeeded " )
msginfo( tostring(oPrnDefaults:pcReturned ) , "Abrindo oPrnDefaults:pcReturned " )

// ClosePrinter( hDC )

else
// msginfo("não passando hDC # 0 " )
RETURN .F.
Endif
else
// msginfo("openprinter " )
RETURN .F.

Endif


//------------------------------------------------------------------------//

DLL32 FUNCTION OpenPrinter( pName AS LPSTR, @pPrinter AS LONG, pDef AS LPSTR ) ;
   AS BOOL PASCAL FROM "OpenPrinterA" LIB "winspool.drv"

//------------------------------------------------------------------------//
DLL32 FUNCTION EnumJobs( hPrinter AS LONG, FirstJob AS DWORD,;
                         NoJobs AS DWORD , Level AS DWORD,;
                         pJob AS LPSTR, cbBuf AS DWORD,;
                         @pcbNeeded AS DWORD , @pcReturned AS DWORD ) ;
                         AS LONG PASCAL ;
                         FROM "EnumJobsA" LIB "winspool.drv"
                         
//------------------------------------------------------------------------//

/*
BOOL EnumJobs(
__in HANDLE hPrinter,
__in DWORD FirstJob,
__in DWORD NoJobs,
__in DWORD Level,
__out LPBYTE pJob,
__in DWORD cbBuf,
__out LPDWORD pcbNeeded,
__out LPDWORD pcReturned
);
*/
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42117
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 73 guests