Hello,

I have a problem with the AddPrinter Functionality from Windows.
I have code that adds a printer to my list.
I am a local Admin, so i can add a printer in source
I can also add a printer with Add Printer from the Printers Tab in
Windows.

A normal user in our company does not have Admin Rights.
He/She is able to add printers using the windows Add Printer
functionality, but when i try with the same piece of code, it does not
add the printer. There is no error, but at the same time, nothing
happens. The code is not my own, i picked it up somewhere from
Internet, but i changed it some places. So, it might look familiair :)
Here is the code:


// sName := \\PRINTQUEUE\PRINTER100
// sPort := LPT1:
// sDriver := Xerox Wordcentre M35 PCL6
Function SKAAddPrinter(sName, sPort, sDriver: String): Boolean;
var
  iLevel: DWORD;
  pPrinter: PPrinterInfo2;
begin

  iLevel := 2;
  New(pPrinter);
  with pPrinter^ do begin

    pServerName := nil;
    pPrinterName := PChar(sName);
    pShareName := PChar(sName);
    pPortName := PChar(sPort); // LPT1:
    pDriverName := PChar(sDriver); // Xerox Wordcentre M35 PCL6
    pPrintProcessor := 'WinPrint';
    pDataType := 'RAW';
    Attributes := PRINTER_ATTRIBUTE_LOCAL Or PRINTER_ATTRIBUTE_SHARED;

    pComment := nil;
    pLocation := nil;
    pDevMode := nil;
    pSepFile := nil;
    pParameters := nil;
    pSecurityDescriptor := nil;
    Priority := 0;
    DefaultPriority := 0;
    StartTime := 0;
    UntilTime := 0;
    Status := 0;
    cJobs := 0;
    AveragePPM :=0;

  end;

  Result := (AddPrinter(pPrinter^.pServerName, iLevel, pPrinter) <> 0);

end;

TIA
Marco

Reply via email to