想把CLIENTSOCKET编译成一个DLL,可以吗

xpzhou 2006-09-13 08:20:15
想编写一个DLL,供PB调用,传入两个参数,服务器IP地址,发送内容。程序如下,在PB里运行却报错。请问如何处理?
library clientsocket;

{ 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
SysUtils,
ScktComp,
Classes;

{$R *.res}
function sendmsg(svr_ip , send_text : string) : integer; stdcall;
var
ClientSocket1: TClientSocket;
begin
ClientSocket1.Address:=svr_ip;
ClientSocket1.port:=2058;
ClientSocket1.Active:= false;
ClientSocket1.Active:= true;
ClientSocket1.Socket.SendText(send_text);
result:=1;

end;
exports
sendmsg;
begin
end.

编译时,有如下提示:[Warning] clientsocket.dpr(23): Variable 'ClientSocket1' might not have been initialized,有关系吗?另外到底是用INDY的IDTCPCLIENT好还是D7自己的CLIENTSOCKET好
...全文
183 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
postren 2006-09-13
  • 打赏
  • 举报
回复
另外,用阻塞模式

ClientSocket1.ClientType := ctBlocking;
postren 2006-09-13
  • 打赏
  • 举报
回复
不能用string 用pchar代替

1,593

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 网络通信/分布式开发
社区管理员
  • 网络通信/分布式开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧