Вверх ↑
Ответов: 1528
Рейтинг: 57
#1: 2011-10-28 13:32:58 ЛС | профиль | цитата
1nd1g0, нет мне нужен список принтеров в сети
print.jpg
------------ Дoбавленo в 13.32:
накопал на делфях кое что
компонент PRINTER_ENUM бы в палитру


#pas
procedure TMainScreen.BtnEnumClick(Sender: TObject);
var
Level : Byte;
Buffer, PrinterInfo : PChar;
i : Integer;
Flags, Count, NumInfos : DWORD;
liPrn : TListItem;
begin
// Flush any previous content of the visula printer list
LvPrinters.Items.Clear;
//
// We need different version of PRINTERINFO
// depending of Windows version
if Win32Platform = VER_PLATFORM_WIN32_NT then begin
// Under NT ENUM_CONNECTIONS will work fast, because
// it does not perfrom real RPC calls, but uses internal NT
// "history" instead.
Flags := PRINTER_ENUM_CONNECTIONS or PRINTER_ENUM_LOCAL;
Level := 4;
end
else begin
// Under Win9x ENUM_LOCAL will return even network devices,
// because, in fact, all information will be retrieved from Registry
Flags := PRINTER_ENUM_LOCAL;
Level := 5;
end;
//
// Determine, how much memory do we need for the printer
// list and allocate necessary buffer.
Count := 0;
EnumPrinters( Flags, nil, Level, nil, 0, Count, NumInfos );
if Count = 0 then Exit;
GetMem( Buffer, Count );
//
try
// Retrieve printer list
if not EnumPrinters( Flags, nil, Level, PByte(Buffer), Count, Count, NumInfos ) then
Exit;
PrinterInfo := Buffer;
//
// Walk through the printer list and put an information
// about each printer to our own ListView
for i := 0 to NumInfos - 1 do begin
liPrn := LvPrinters.Items.Add;
//
if Level = 4 then begin
// Process PRINTER_INFO_4 data
liPrn.Caption := PPrinterInfo4(PrinterInfo)^.pPrinterName;
if (PPrinterInfo4(PrinterInfo)^.Attributes and PRINTER_ATTRIBUTE_NETWORK) <> 0
then liPrn.subItems.Add( 'network' )
else liPrn.SubItems.Add( 'local' );
Inc( PrinterInfo, SizeOf(TPrinterInfo4) );
end
else begin
// Process PRINTER_INFO_5 data
liPrn.Caption := PPrinterInfo5(PrinterInfo)^.pPrinterName;
if (PPrinterInfo5(PrinterInfo)^.Attributes and PRINTER_ATTRIBUTE_SHARED) <> 0
then liPrn.subItems.Add( 'shared' )
else liPrn.SubItems.Add( '' );
Inc( PrinterInfo, SizeOf(TPrinterInfo5) );
end;
end;
finally
FreeMem( Buffer, Count );
end;
end;
[url=http://forum.ixbt.com/topic.cgi?id=40:657]исходная тема+скрины работы[/url]
карма: 0

0