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;
     

  • 相关阅读:
    Python进阶-----类、对象的属性的增删改查
    SpringCloud(Finchley版) 服务注册与服务发现-Eureka原理深入
    SpringCloud项目之Eureka 配置 application.yml
    sql 获得各科最高分成绩和人数
    mysql主从同步
    Log4j.properties
    JDBC 配置 jdbc.properties
    Java 通过ant打包时给JS/Jsp/css等文件加上版本号 防止有缓存
    Ant 打包 build文件
    Java zip 压缩包下载excel文件
  • 原文地址:https://www.cnblogs.com/maweiwei/p/13728311.html
Copyright © 2011-2022 走看看