想写个dll库,里面会使用TClientSocket,但不用TFORM怎样使用?

weige250 2014-11-12 02:14:11
之前用TClientSocket都是把这个控件放在form上使用,

现在想写个dll库,纯粹执行socket的连接,数据收发,不要界面显示,该怎样做?
...全文
796 13 打赏 收藏 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
kwer 2015-08-31
  • 打赏
  • 举报
回复
这个不算事吧,放到data module 里面,然后DLL调用DM.Create 就可以了
lyhoo163 2014-11-14
  • 打赏
  • 举报
回复
还有一种方式: 1、将TClientSocket放在调用DLL的Form上; 2、Dll通过共用内存,调用From上的 TClientSocket;
xiexuan2007 2014-11-14
  • 打赏
  • 举报
回复
用这种方式创建看也 TClientDataSet.Create(Application);
Playmaster 2014-11-14
  • 打赏
  • 举报
回复
引用 9 楼 weige250 的回复:
调用dll的工程里,引用时,没加stdcall导致
嗯,有可能
weige250 2014-11-14
  • 打赏
  • 举报
回复
调用dll的工程里,引用时,没加stdcall导致
s11ss 2014-11-13
  • 打赏
  • 举报
回复
function connectphone(port: integer):boolean;stdcall;export; begin Csocket :=TClientSocket.Create(nil); csocket.Free; result :=true; end; 不使用Csocket了才释放啊,怎么刚创建就释放了啊。。。
Playmaster 2014-11-13
  • 打赏
  • 举报
回复
引用 5 楼 weige250 的回复:
[quote=引用 4 楼 Playmaster 的回复:] 你就在dll中把创建,接收,发送,关闭函数暴露给调用者就行了,不必把tclientsocket暴露出来。 在你的创建接收发送关闭函数里使用tclientsocket处理通讯就行了。
我把这段代码放在函数connectphone里也是不行啊 var Csocket: TClientSocket;[/quote] 这应该是别的地方引起的问题。你检查一下其他代码。 Csocket应该是个dll中全局变量,这样在dll中的多个函数都可以使用,或者创建个单例模式的类。
lyhoo163 2014-11-12
  • 打赏
  • 举报
回复
From也可放入Dll中。
weige250 2014-11-12
  • 打赏
  • 举报
回复
引用 4 楼 Playmaster 的回复:
你就在dll中把创建,接收,发送,关闭函数暴露给调用者就行了,不必把tclientsocket暴露出来。 在你的创建接收发送关闭函数里使用tclientsocket处理通讯就行了。
我把这段代码放在函数connectphone里也是不行啊 var Csocket: TClientSocket;
Playmaster 2014-11-12
  • 打赏
  • 举报
回复
你就在dll中把创建,接收,发送,关闭函数暴露给调用者就行了,不必把tclientsocket暴露出来。 在你的创建接收发送关闭函数里使用tclientsocket处理通讯就行了。
weige250 2014-11-12
  • 打赏
  • 举报
回复
江湖救急啊。。。。。。。。。。。
weige250 2014-11-12
  • 打赏
  • 举报
回复
引用 1 楼 s11ss 的回复:
o:=TClientSocket.Create(nil); .... o.Free;
我根据你说的,好像不行啊,调用的时候提示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.
s11ss 2014-11-12
  • 打赏
  • 举报
回复
o:=TClientSocket.Create(nil); .... o.Free;
附训练好的 YOLO 权重与 PyQt 可视化检测界面,页面底部含可视化效果预览,毕设/课设开箱即用。 【数据集概况】 · 检测类别(中文):[坡道(ramp)] · 训练集:275 张 · 验证集:27 张 · 测试集:0 张 · 总计:302 张 该数据集聚焦于城市环境中各类建筑入口处的坡道设施,涵盖住宅、商铺、公共设施等多种场景,真实反映了无障碍通行设施在实际应用中的多样化形态。数据集中包含金属、橡胶、塑料等多种材质的坡道,以及不同尺寸、结构和安装方式的实例,充分体现了坡道在城市基础设施中的广泛部署与重要性。该数据集为城市智慧化管理、无障碍环境建设及公共安全监控提供了高质量的视觉基础支持。... 【训练曲线与评估图】 【模型训练配置】 参数 | 值 模型 | yolo26n 训练轮数 | 100 epochs 输入尺寸 | 640x640 批次大小 | 24 优化器 | auto 初始学习率 | 0.01 训练设备 【关键指标汇总】 训练了 33 个 epoch,最终轮指标: 指标 | 数值 mAP50 | **0.6372** mAP50-95 | 0.3401 Precision | 0.6603 Recall | 0.6190 train/box_loss | 1.0569 train/cls_loss | 0.7307 val/box_loss | 1.6084 val/cls_loss | 1.9323 【训练过程分析】 33 轮训练后 mAP50 仅 0.6372,模型收敛不充分。Loss 曲线前期下降后进入平台期,mAP 提升缓慢。mAP50-95 为 0.3401,定位精度同样偏低。 【模型性能评估】 Precision 0.6603、Recall 0.6190,精度高于召回,存在一... 使用场景:毕业设计、课程设计、深度学习入门、工业场景落地验证。

1,594

社区成员

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

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