unit Unit1;{$WARN SYMBOL_PLATFORM OFF}interfaceuses
  ComObj, ActiveX, iprttest3_TLB, StdVcl,Printers,Windows;type
  Tprint = class(TAutoObject, Iprint)
  protected
    procedure printtext; safecall;  end;implementationuses ComServ;procedure Tprint.printtext;
var
  Device: array[0..255] of char;
  Driver: array[0..255] of char;
  Port: array[0..255] of char;
  hDMode: THandle;
  PDMode: PDEVMODE;
begin
//设置打印机
  Printer.PrinterIndex := Printer.PrinterIndex;
  Printer.GetPrinter(Device, Driver, Port, hDMode);
  if hDMode <> 0 then
  begin
    pDMode := GlobalLock(hDMode);
    if pDMode <> nil then
    begin
        //设定纸张类型
        pDMode^.dmFields := pDMode^.dmFields or
          DM_PAPERSIZE  ;
          pDMode^.dmPaperSize := DMPAPER_A4;
      GlobalUnlock(hDMode);
    end;
  end ;
  Printer.PrinterIndex := Printer.PrinterIndex;
  Printer.BeginDoc;
  Printer.Canvas.TextOut(100,100,'sssssssssss');
  Printer.EndDoc;
end;initialization
  TAutoObjectFactory.Create(ComServer, Tprint, Class_print,
    ciMultiInstance, tmApartment);
end.asp代码
<% @Language = "VBScript" %>
<html>
<%
sub testprtobject  
dim prtobject
set prtobject=createobject("iprttest3.print")  
prtobject.printtext 
set prtobject=nothing  
end sub 
testprtobject()
%>错误类型:
iprttest3.print (0x8000FFFF)
/print/print.asp, 第 7 行

解决方案 »

  1.   

    这一句有误:
    set prtobject=createobject("iprttest3.print")  
    应为:
    set prtobject=createobject("iprttest3.Tprint")  
    这是由于你所建立的类名为Tprint所致.
      

  2.   

    我在客户端,注册了组件。旧可以了,难道automation要在客户端注册吗?ie不能自动下载注册呀!我想在客户端实现打印功能呀!
      

  3.   

    这种组件在ASP代码调用时好象不能实现打印功能吧!(不可视的对象)
    automation应该也不能在客户端注册
      

  4.   

    可以亚,已经实现了打印功能,后面的的问题是,如何用websnop  或 intraweb调用我可不想用asp呀!以及打印参数的传递问题!