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;
     

  • 相关阅读:
    窗口的基本手势事件处理
    用户自定义手势,并识别
    安卓程序国际化,手机屏幕适配器
    排序:冒泡,快排,归并。
    哈夫曼树学习
    二叉树的学习。
    ArrayList和vector的区别
    关于try-catch-finally return 的面试题
    Java中的抽象和封装
    关于SelectedValue的众多解决方案
  • 原文地址:https://www.cnblogs.com/maweiwei/p/13728311.html
Copyright © 2011-2022 走看看