Windows API: EnumForms如何使用,请给出实际例子,尤其是各参数的用法(如题,无内容)(30分)

  • 主题发起人 主题发起人 阿朱
  • 开始时间 开始时间
请大家看一下我的代码有什么错,为什么枚举出来的是全部的格式(即在打印机设置中的服务器属性中列出的)<br>而不是当前打印机支持的格式。<br>uses Printers, WinSpool;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br>&nbsp; cbBuf, FormsInfo: Pchar;<br>&nbsp; pcbNeeded, pcReturned: DWORD;<br>&nbsp; I: Integer;<br>&nbsp; Level: Byte;<br>&nbsp; PrinterName: String;<br>&nbsp; hPrinter: THandle;<br>begin<br>&nbsp; PrinterName := Printer.Printers.Strings[Printer.PrinterIndex];<br>&nbsp; hPrinter := 0;<br>&nbsp; if not OpenPrinter(Pchar(PrinterName), hPrinter, nil) then Exit;<br>&nbsp; Level := 1;<br>&nbsp; pcbNeeded := 0;<br>&nbsp; EnumForms(hPrinter, Level, nil, 0, pcbNeeded, pcReturned);<br>&nbsp; if pcbNeeded = 0 then Exit;<br>&nbsp; GetMem(cbBuf, pcbNeeded);<br>&nbsp; if not EnumForms(hPrinter, Level, PByte(cbBuf), pcbNeeded, pcbNeeded,pcReturned) then Exit;<br>&nbsp; FormsInfo := cbBuf;<br>&nbsp; for I := 0 to pcReturned - 1 do<br>&nbsp; begin<br>&nbsp; &nbsp; ListBox1.Items.add(PFormInfo1(FormsInfo)^.pName);<br>&nbsp; &nbsp; Inc(FormsInfo, sizeof(Form_INFO_1));<br>&nbsp; end;<br>&nbsp; FreeMem(cbBuf);<br>end;
 
请斑竹Help Me.<br>cAKK,Where are you?<br>
 
阿朱:如果你还要继续讨论请定期提前你的帖子,如果不想继续讨论请结束帖子。<br>
 
接受答案了.
 
后退
顶部