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;
     

  • 相关阅读:
    CF1153C. Serval and Parenthesis Sequence
    LGOJ P2048 [NOI2010]超级钢琴
    BZOJ4551: [Tjoi2016&Heoi2016]树
    性能分析 | Java进程CPU占用高导致的网页请求超时的故障排查
    SQL优化 | sql执行过长的时间,如何优化?
    性能优化 | JVM性能调优篇——来自阿里P7的经验总结
    性能优化 | 线上百万级数据查询接口优化过程
    性能分析 | 线上CPU100%排查
    性能测试 | Web端性能测试
    自动化测试 | 好用的自动化测试工具Top 10
  • 原文地址:https://www.cnblogs.com/maweiwei/p/13728311.html
Copyright © 2011-2022 走看看