Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Urgent :Printer Status in PRINTER_INFO_2

Urgent :Printer Status in PRINTER_INFO_2

Scheduled Pinned Locked Moved C / C++ / MFC
swifthelp
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jaffer Mumtaz
    wrote on last edited by
    #1

    #include "Windows.h" #include "WinSpool.h" #include "Winbase.h" char* cube() { char buff[1024]; GetProfileString("PrinterPorts",NULL,NULL,buff,sizeof(buff)); int length,j; length=strlen(buff); char *token; char sep[]="|"; for (j=0;j<1024;j++) { if(buff[j]==NULL) buff[j]='|'; } token = strtok( buff,sep); j=0; HANDLE hPrinter=NULL; PRINTER_INFO_2 *ppi2 = NULL; BOOL bFlag; unsigned long dwNeeded; DWORD dWord; long Status; char *portnumber,*strName; //DWORD dError; while( token != NULL ) { bFlag=OpenPrinter(token,&hPrinter,NULL); dWord=GetLastError(); if(bFlag==1) { bFlag= GetPrinter(hPrinter,2,0 ,0,&dwNeeded); ppi2 = (PRINTER_INFO_2 *)GlobalAlloc(GPTR, dwNeeded); bFlag= GetPrinter(hPrinter,2,(LPBYTE)ppi2 ,dwNeeded,&dwNeeded); if (bFlag==1) { return token; Status=1; Status=ppi2->Status; portnumber=ppi2->pPortName; strName=ppi2->pShareName; //dError=GetLastError(); ClosePrinter(hPrinter); exit(0); } } // SetDefaultPrinter(token); token = strtok( NULL, sep); ClosePrinter(hPrinter); } token=NULL; return token; } Hi can any one tell me whts wrong with the code. the status returned by PRINTER_INFO_2 is 0 every time. while the OpenPrinter and GetPrinter are returning 1 meaning successfully returning values of the printer. i dont no why everytime status is 0. can any body help me out. waiting for swift reply

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups