请大家看一下我的代码有什么错,为什么枚举出来的是全部的格式(即在打印机设置中的服务器属性中列出的)<br>而不是当前打印机支持的格式。<br>uses Printers, WinSpool;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> cbBuf, FormsInfo: Pchar;<br> pcbNeeded, pcReturned: DWORD;<br> I: Integer;<br> Level: Byte;<br> PrinterName: String;<br> hPrinter: THandle;<br>begin<br> PrinterName := Printer.Printers.Strings[Printer.PrinterIndex];<br> hPrinter := 0;<br> if not OpenPrinter(Pchar(PrinterName), hPrinter, nil) then Exit;<br> Level := 1;<br> pcbNeeded := 0;<br> EnumForms(hPrinter, Level, nil, 0, pcbNeeded, pcReturned);<br> if pcbNeeded = 0 then Exit;<br> GetMem(cbBuf, pcbNeeded);<br> if not EnumForms(hPrinter, Level, PByte(cbBuf), pcbNeeded, pcbNeeded,pcReturned) then Exit;<br> FormsInfo := cbBuf;<br> for I := 0 to pcReturned - 1 do<br> begin<br> ListBox1.Items.add(PFormInfo1(FormsInfo)^.pName);<br> Inc(FormsInfo, sizeof(Form_INFO_1));<br> end;<br> FreeMem(cbBuf);<br>end;