{ ////////////////////////////////////////////////////////////
//
//
//////////////////////////////////////////////////////////// }
library usoftwebsvc;
{%DelphiDotNetAssemblyCompiler '$(SystemRoot)\microsoft.net\framework\v1.1.4322\System.Web.Services.dll'}
{%WebRefCreator 'Web References\websvc'}
{%WebRefCreator 'Web References\websvc\SoftWebSvc.map'}
{%WebRefCreator 'Web References\websvc\SoftWebSvc.wsdl'}
{%WebRefCreator 'Web References\websvc\SoftWebSvc.disco'}
{%DelphiDotNetAssemblyCompiler 'c:\program files\borland\bds\2.0\bin\IndyNetCore.dll'}
{%DelphiDotNetAssemblyCompiler 'c:\program files\common files\borland shared\bds\shared assemblies\2.0\Borland.Delphi.dll'}
{%DelphiDotNetAssemblyCompiler 'c:\program files\common files\borland shared\bds\shared assemblies\2.0\Borland.VclRtl.dll'}
{%DelphiDotNetAssemblyCompiler '$(SystemRoot)\microsoft.net\framework\v1.1.4322\System.dll'}
{%DelphiDotNetAssemblyCompiler '$(SystemRoot)\microsoft.net\framework\v1.1.4322\System.Data.dll'}
{%DelphiDotNetAssemblyCompiler '$(SystemRoot)\microsoft.net\framework\v1.1.4322\System.XML.dll'}
{%DelphiDotNetAssemblyCompiler 'comimports\Interop.SHDocVw.dll'}
{%DelphiDotNetAssemblyCompiler 'comimports\AxInterop.SHDocVw.dll'}
{%DelphiDotNetAssemblyCompiler 'comimports\AxInterop.MSWinsockLib.dll'}
{%DelphiDotNetAssemblyCompiler 'c:\program files\borland\bds\2.0\bin\IndyNet.dll'}uses
//???第一个问题使用了ShareMem后,出现错误:[Fatal Error] usoftwebsvc.dpr(28): File not found: 'ShareMem.dcuil'  ShareMem,   
  SysUtils,
  Classes,
  System.Reflection,
  websvc.SoftWebSvc in 'Web References\websvc\websvc.SoftWebSvc.pas',
  Unitwinsock in 'Unitwinsock.pas';
//  ,Unitbrowse in 'Unitbrowse.pas';function NetChk(hostserver:string ; hostport:integer):boolean; stdcall;exports
    NetChk ;begin
  function NetChk(hostserver:string ; hostport:integer):boolean; stdcall;
  begin
      PingHost(hostserver;hostport);
  end;  end.
{///////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////}
unit Unitwinsock;interfaceuses
  SysUtils, Variants, Classes, System.ComponentModel, IdBaseComponent, IdComponent,
  IdTCPConnection, IdTCPClient;
//ShareMem,??? ---->Why not use ittype
    TCPClient= class(TIdTCPClient);
    function PingHost(hostserver :string;hostport:integer ):boolean;stdcall;
    //function DoSocketGet(server:string,errmsg:string):integer;
    //function connect:boolean;stdcall;external 'wsock32.dll';
var
  { Public declarations }
     tcpclt:TCPClient;
     retval:boolean;implementation function PingHost(hostserver :string;hostport:integer):boolean; stdcall;
    begin
      try
        tcpclt.Port:=hostport;
        tcpclt.Host:=hostserver;
        retval:=tcpclt.Connected();
      finally
        tcpclt.Destroy;
      end;
      result:= retval ;
    end;end.在注释ShareMem后,出现编译错误:
[Error] Unitwinsock.pas(26): Procedure definition must be ILCODE calling convention
[Fatal Error] usoftwebsvc.dpr(28): Could not compile used unit 'Unitwinsock.pas'我是个新手,现在想做成一个标准dll文件,能在vb工具中调用;请高手帮忙解决一下,明天上午就要用的很急,先谢勒。                        
QQ :251330151  
MSN:[email protected]

解决方案 »

  1.   

    DLL接口不要使用String类型,也最好不要用ShareMem的!
    改用PChar就没问题的http://lysoft.7u7.net
      

  2.   

    恩,谢谢,我之前也查了历史帖子,也是这么说的,可我觉得如果用string,问题一:那ShareMem该如何解决呢?问题二:在注释ShareMem后,出现编译错误:
    [Error] Unitwinsock.pas(26): Procedure definition must be ILCODE calling convention
    [Fatal Error] usoftwebsvc.dpr(28): Could not compile used unit 'Unitwinsock.pas'还请围绕这个主题讨论~~~出次发帖,请多大家关照!信誉为上~
      

  3.   

    platform: Delphi 8 { ////////////////////////////////////////////////////////////
    //
    //
    //////////////////////////////////////////////////////////// }
    library usoftwebsvc;
    {%DelphiDotNetAssemblyCompiler '$(SystemRoot)\microsoft.net\framework\v1.1.4322\System.Web.Services.dll'}
    {%WebRefCreator 'Web References\websvc'}
    {%WebRefCreator 'Web References\websvc\SoftWebSvc.map'}
    {%WebRefCreator 'Web References\websvc\SoftWebSvc.wsdl'}
    {%WebRefCreator 'Web References\websvc\SoftWebSvc.disco'}
    {%DelphiDotNetAssemblyCompiler 'c:\program files\borland\bds\2.0\bin\IndyNetCore.dll'}
    {%DelphiDotNetAssemblyCompiler 'c:\program files\common files\borland shared\bds\shared assemblies\2.0\Borland.Delphi.dll'}
    {%DelphiDotNetAssemblyCompiler 'c:\program files\common files\borland shared\bds\shared assemblies\2.0\Borland.VclRtl.dll'}
    {%DelphiDotNetAssemblyCompiler '$(SystemRoot)\microsoft.net\framework\v1.1.4322\System.dll'}
    {%DelphiDotNetAssemblyCompiler '$(SystemRoot)\microsoft.net\framework\v1.1.4322\System.Data.dll'}
    {%DelphiDotNetAssemblyCompiler '$(SystemRoot)\microsoft.net\framework\v1.1.4322\System.XML.dll'}
    {%DelphiDotNetAssemblyCompiler 'comimports\Interop.SHDocVw.dll'}
    {%DelphiDotNetAssemblyCompiler 'comimports\AxInterop.SHDocVw.dll'}
    {%DelphiDotNetAssemblyCompiler 'comimports\AxInterop.MSWinsockLib.dll'}
    {%DelphiDotNetAssemblyCompiler 'c:\program files\borland\bds\2.0\bin\IndyNet.dll'}uses
      SysUtils,
      Classes,
      System.Reflection,
      websvc.SoftWebSvc in 'Web References\websvc\websvc.SoftWebSvc.pas',
      Unitwinsock in 'Unitwinsock.pas',
      Unitbrowse in 'Unitbrowse.pas';function NetChk(hostserver:pChar ; hostport:integer):boolean; stdcall;exports
        NetChk ;begin
      function NetChk(hostserver:pChar ; hostport:integer):boolean; stdcall;
      begin
          PingHost(hostserver;hostport);
      end;  end.{///////////////////////////////////////////////////////////////////
    //
    ///////////////////////////////////////////////////////////////////}
    unit Unitwinsock;interfaceuses
      SysUtils, Variants, Classes, System.ComponentModel, IdBaseComponent, IdComponent,
      IdTCPConnection, IdTCPClient;
    //ShareMem,??? ---->Why not use ittype
      TCPClient= class(TIdTCPClient);
      function PingHost(hostserver :pChar;hostport:integer ):boolean;stdcall;var
      tcpclt:TCPClient;
      retval:boolean;implementation function PingHost(hostserver :pChar;hostport:integer):boolean; stdcall;
        begin
          try
            tcpclt.Port:=hostport;
            tcpclt.Host:=hostserver;
            retval:=tcpclt.Connected( );
          finally
            tcpclt.Destroy;
          end;
          result:= retval ;
        end;end.
    编译结果:
    [Error] Unitwinsock.pas(15): Unsafe pointer variables, parameters or consts only allowed in unsafe procedure
    [Error] Unitwinsock.pas(23): Unsafe pointer variables, parameters or consts only allowed in unsafe procedure
    [Error] Unitwinsock.pas(24): Procedure definition must be ILCODE calling convention
    [Error] Unitwinsock.pas(27): Incompatible types: 'string' and 'PWideChar'
    [Fatal Error] usoftwebsvc.dpr(28): Could not compile used unit 'Unitwinsock.pas'
      

  4.   

    { 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. }
      

  5.   

    这里的delphi高手,咋就这水平啊,还没有解决问题!~对不起大家,不能给分!