zoukankan      html  css  js  c++  java
  • dll pansichar 报错

    library dll10;
     
    { Important note about DLL memory management: ShareMem must be the
    first unit in your library's USES clause AND your project's (select
    Project-View Source) USES clause if your DLL exports any procedures or
    functions that pass strings as parameters or function results. This
    applies to all strings passed to and from your DLL--even those that
    are nested in records and classes. ShareMem is the interface unit to
    the BORLNDMM.DLL shared memory manager, which must be deployed along
    with your DLL. To avoid using BORLNDMM.DLL, pass string information
    using PChar or ShortString parameters. }
     
    uses
    System.ShareMem,
    System.SysUtils,
    System.Classes,
    Soap.InvokeRegistry,
    Soap.SOAPHTTPClient,
    System.Types,
    Soap.XSBuiltIns,
    n_socialwebservice in 'n_socialwebservice.pas';
     
    {$R *.res}
    function dllstr(const input: PAnsiChar; var output: PAnsiChar): Integer; stdcall;
    begin
    StrCopy(output, input);
    Result := 1;
    end;
     
    function getexamine(const as_type: PAnsiChar; const as_code: PAnsiChar; var as_sresult: PAnsiChar; var as_smessage: PAnsiChar): SmallInt; stdcall;
    var
    ahttp: THTTPRIO;
    s3, s4: string;
    s5, s6: PAnsiChar;
    begin
    try
    ahttp := THTTPRIO.Create(nil);
    ahttp.URL := 'http://218.7.121.38:11111/socialwebservice/n_socialwebservice.asmx';
    ahttp.Service := 'n_socialwebservice';
    ahttp.Port := 'n_socialwebserviceSoap';
    s3 := '';
    s4 := '';
    Result := (ahttp as n_socialwebserviceSoap).of_getexamine(StrPas(as_type), StrPas(as_code), s3, s4);
    // s5 := PAnsiChar(AnsiString(s3));
    // s6 := PAnsiChar(AnsiString(s4));
    //重要
    StrCopy(as_sresult, PAnsiChar(AnsiString(s3)));
    StrCopy(as_smessage, PAnsiChar(AnsiString(s4)));
    Result := 1;
    finally
    // FreeAndNil(ahttp);
    end;
    end;
     
    exports
    dllstr,
    getexamine;
     
    begin
     
    end.
     
     
    initialization
    Coinitialize(nil);
    finalization
    CoUninitialize;
    -----------------------------------------------------------------------------------
    主调用
    -----------------------------------------------------------------------------------
     
    procedure TForm1.btn2Click(Sender: TObject);
    var
    s, s1: PAnsiChar;
    begin
    try
    //重要
    GetMem(s, 1024);
    GetMem(s1, 255);
    getexamine(PAnsiChar(edt1.Text), PAnsiChar(''), s, s1);
    //重要
    mmo1.Text := s;
    edt2.Text := s;
     
    finally
    FreeMem(s);
    FreeMem(s1);
    end;
    end;
     

  • 相关阅读:
    linux tcpdump抓包,wireshark实时解析
    TLS协议分析
    sqlite sql语句关键字GROUP BY的理解
    使用 openssl 生成证书
    linux C单元测试工具CUnit的编译安装及使用
    http短连接大量time wait解决方案
    gdb调试行号错位
    libevent 多线程
    C语言单元测试
    客户端端口分配
  • 原文地址:https://www.cnblogs.com/maweiwei/p/13728311.html
Copyright © 2011-2022 走看看