Socket(客户端)打包到Dll中供pb使用(300分)

J

jfzjm

Unregistered / Unconfirmed
GUEST, unregistred user!
[:)]在目前项目开发过程中,客户所用的应用程序系统是pb6.0开发的,需要将我们我们自己的接口程序内嵌,为其提供数据,这个接口根据实际需要使用了客户机到前置机到中心服务器的方式,综合用户各种情况而使用了socket通讯。但pb6在这块较差(或是本人pb差),现在能够发送数据到delphi中间程序,可接收有点问题,并且在delphi中的常常报错,因此我想将delphi的socket客户端封装起来,做成简单的函数调用,生成一个类似指令集的东西,由中间程序处理,这样也便于他们以后自己改。希望高手们给予指教,由于本人水平有限,最好有源码实例。
 
delphi 的安装目录下 demo 有 sock 的例子啊
 
例子不是我需要的,我的程序都写完了,现在要封装成dll供pb6调用。
 
这个很难吗?
在 library里最后加上个
procedure func1(xxx):xxx;stdcall;//后边加上stdcall或者别的pb支持的传参数的方式
func1是函数名字,
最后边加
exports func1, ..., funcn;
引出函数输出表!dll就OK了
pb6调用dll就不清楚了!
 
通过controls->OLE->Insert Object导入Microsoft Winsock control使用控件;
要不就下载个PowerSocket,可以直接在PB中用
http://www.science.org/jasonc/innovation.html
 
不好意思,刚才那个链接下不了,你自己搜索一下吧,下面是一个PPT教程
http://www.draperconsulting.com/downloads/powrsock.zip
 
谢谢你们的回答,目前可以发,但是接收返回值的就不行了?如果用别的我也可以,但是后期大部分要用户自己写。如果那样,就不好弄了,我想是自己写一个函数,让他们直接用就可以了。
 
pb可以直接调用的,我们经常这样干
function int XX(string ddd) library 'dddd.dll'
 
无论你是超极菜鸟,亦或是绝顶高手,在这里偶们静下心来平等地交流学习:
delphi交流群:4654765(delphi天堂)欢迎您的加入!让我们共同进步!!
帮你顶一下
 
调用我都知道,可是当信息发出后,socket要回传一个信息,如何捕获
 
转一个,参考一下吧
pmele (Programmer) 14 Mar 01 7:41
1) Create your dll with the call.
2) Create a nvo and declare the function aa local or global. For example:
Function boolean GetChildInfoByHwnd(ulong Child, ulong Hwnd, ref str_wobj winfo) Library "Pbenum.dll"
3) Create your function within the nvo:
//************************************************************
// Object: nvo_enum inherited from nonvisualobject
// Function: uf_getchildinfobyhwnd
// Access: public
// Arguments: unsignedlong al_parent
// unsignedlong al
// ref str_wobj astr
// Returns: integer
//************************************************************
str_wobj lstr
Integer li_buf=255
Integer li_rtn
String ls_msg
lstr.WinCaptionBuffer = Space(li_buf)
lstr.WinCaptionSize = li_buf
lstr.WinClassBuffer = Space(li_buf)
lstr.WinClassSize = li_buf
If GetChildInfoByHwnd(al_parent, al, lstr) then
lstr.WinClassBuffer = Trim(lstr.WinClassBuffer)
lstr.WinCaptionBuffer = Trim(lstr.WinCaptionBuffer)
astr = lstr
li_rtn = 1
End If
Return li_rtn
//************************************************************
4) In this function I defined the following structure to pass to the DLL to fill:
$PBExportHeader$str_wobj.srs
$PBExportComments$Window structure for DLL calls
global type str_wobj from structure
unsignedlong winhandle
integer processid
boolean isvisible
boolean isenabled
boolean isiconic
string wincaptionbuffer
unsignedlong wincaptionsize
string winclassbuffer
unsignedlong winclasssize
str_rect rect
end type

Thats it! In this example I used Delphi to create the DLL function and the actual call to the Windows callback.

Paul Mele
DFAS-CL/TSAD
 
谢谢,不过这个对我似乎没什么用
 
pb一般只能做直连,本地数据库,然后刷新,没什么说的.
最好转到delphi来
 
我已经用pb和delphi进行过socket通讯,可是让用户用PB来编写或修改socket就不现实,必竟用户的水平有限(pb6.0,原来系统研发公司和他们单位也不联系了,他们每次在原码上自行修改)因此想到了这个方法,类似的方法我见过,可不知道怎么实现的.
 
顶部