即在delphi中写一个dll实现:
     打开串口     发送数据     操作完毕后关闭串口

解决方案 »

  1.   

    有很多选择:API,MSComm,SPComm,。
      

  2.   

    HOHO,实在是没有时间帮你写了!Dll原理都差不多,自己写写吧!
      

  3.   

    用 spcomm 控件吧,比较简单的,跟你在普通程序中使用一样,注意输出需要的函数即可,
    我做过。
      

  4.   

    library lib1;
    .....
    exports
      OpenComm;
      SendText;
      CloseComm;
    begin
     ...
    end.
    unit unit1;interface
     uses
       ActiveX,....procedure OpenComm(Port:Integer);stdcall;
    procedure SendText(Text:PChar);stdcall;
    procedure CloseComm;stdcall;implementationprocedure OpenComm(Port:Integer);
    begin
      MSComm1.CommPort:=1;
      MSComm1.Open;
    end;
    procedure SendText(Text:PChar);
    begin
      MSComm1.Output:=string(Text);
    end;
    procedure CloseComm;
    begin
     MSComm1.Close;
    end;
    initialization
      CoIntialize(nil);
      MSComm1:=TMSComm.Create(nil);
    finalization
      MSComm1.Free;
      CoUnitialize;
    end.
      

  5.   

    hiflower(花) 您好??哪该怎么接收数据。在这里面。
      

  6.   

    最好接收时在dll中转化好的传回来,
      

  7.   

    exports
      SetCallback;type
       TCallback=procedure(s:string);
       TABC=class(TComponent)
         procedure MSCommOnComm(Sender:TObject);
       end; 
    var
      FCallback:TCallback;
      ABC:TABC;procedure SetCallback(ACallback:TCallback);
    begin
      FCallback:=@ACallback;
    end;
    procedure TABC.MSCommComm(Sender:TObject);
    var
      s:string;
    begin
      while MSComm1.InBufferCount>0 do
      begin
        s:=MSComm1.Input;
        if Assigned(FCallback) then
           FCallback(PChar(s));
      end;
    end;initialization
      ...
      ABC:=TABC.Create(nil); 
      MSComm1.OnComm:=ABC.MSCommOnComm
    finalization
     ...
      ABC.Free;
    end.
      

  8.   

    dll请问上面这段程序,外部应怎么调用。