function connectphone(port: integer):boolean;stdcall;export;
begin
Csocket :=TClientSocket.Create(nil);
csocket.Free;
result :=true;
end;
不使用Csocket了才释放啊,怎么刚创建就释放了啊。。。
我根据你说的,好像不行啊,调用的时候提示Access violation at address 0311.... write of address 0000008c
unit socketunit;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, System.Win.ScktComp, SHELLAPI,
Web.Win.Sockets, Vcl.ExtCtrls;
var
Csocket: TClientSocket;
function connectphone(port: integer):boolean;stdcall;export
implementation
function connectphone(port: integer):boolean;stdcall;export;
begin
Csocket :=TClientSocket.Create(nil);
csocket.Free;
result :=true;
end;
end.
library landidll;
{ 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.SysUtils,
System.Classes,
windows,
messages,
socketunit in 'socketunit.pas';
{$R *.res}
exports
connectphone;
begin
end.