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
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