Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

EnumPrinters does not work,,, help me qiuck

Status
Not open for further replies.

agnidev

Programmer
Nov 5, 2003
1
IN
this code for EnumPrinters does not work for the Remote Printer. when my workstation is using the server print driver it is remote printer . so i want to generate a log file for my print command activity in my system but not getting the proper driver name . please some one help quick


void GetPrinterData()
{

PRINTER_INFO_1* pPrint;
DWORD pcbNeeded=0,pcbReturned=0;
HANDLE hPrinter = INVALID_HANDLE_VALUE;


char str[100];
SYSTEMTIME st;


FILE *fPrinter,*fJob;

fPrinter=fopen("C:\\printer.log","a+");

fJob=fopen("C:\\job.log","a+");



BOOL ret=EnumPrinters(PRINTER_ENUM_REMOTE,NULL,1,NULL,0,&pcbNeeded,&pcbReturned);

pPrint=(PRINTER_INFO_1*)malloc(pcbNeeded);



ret=EnumPrinters(PRINTER_ENUM_REMOTE,NULL,1,(LPBYTE)pPrint,pcbNeeded,&pcbNeeded,&pcbReturned);

fprintf(fPrinter,"%s\n%s\n%s\n%d",pPrint->pName,pPrint->pDescription,pPrint->pComment,pPrint->Flags);

fclose(fPrinter);

BOOL bOK = OpenPrinter(pPrint->pName,
&hPrinter,
NULL); // \\RABCO\Samsung ML-4600 PCL 6

if(!bOK)
{
printf("printer can not open(%d)\n");
InformError();
return;
}


this is my code

please check it and give the updated code .....

it is very very urgent...

sailesh kumar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top