用VB编写的EXE窗体程序能不能和嵌在网页中的ocx进行通信,怎么样通信?ocx也是VB编写的。

Brune 2005-07-26 10:56:34
用VB编写的EXE窗体程序能不能和嵌在网页中的ocx进行通信,怎么样通信?ocx也是VB编写的。

VB编写了一个运行到拖盘的程序。在这个程序里点击某一按钮,与嵌在网页中的ocx通信,使得网页知道VB写的那个程序进行了某个操作。
...全文
150 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
fu0212 2005-07-26
  • 打赏
  • 举报
回复
共享内存 就可以实现了MAP
angeltimes 2005-07-26
  • 打赏
  • 举报
回复
用sokect进行通信

服务器端

Option Explicit
Private Const winsk_local_port = 8888
Private Const max_sessions = 10

Private Sub Form_Load()
Form1.Show
Dim i As Integer
With Winsk(0)
.Protocol = sckTCPProtocol
.LocalPort = winsk_local_port
.Listen
End With
For i = 1 To max_sessions
Load Winsk(i)
Winsk(i).Protocol = sckTCPProtocol
Winsk(i).LocalPort = winsk_local_port
Next
End Sub

Private Sub Winsk_ConnectionRequest(Index As Integer, ByVal requestID As Long)
Dim str As String
Dim i As Integer

If Index = 0 Then
For i = 0 To max_sessions
With Winsk(i)
If .State = sckClosed Then
.Accept requestID
Exit For
End If
End With
Next
End If


End Sub

Private Sub Winsk_DataArrival(Index As Integer, ByVal bytesTotal As Long)
Dim str As String
Dim rc As Integer
Dim i As Integer
MsgBox "收到!"
Winsk(Index).GetData str, , bytesTotal

For i = 1 To max_sessions
With Winsk(i)
If .State = sckConnected Then
.SendData str
DoEvents
End If
End With
Next
End Sub


客户端ocx

Private Sub client_DataArrival(ByVal bytesTotal As Long)
Dim str As String
client.GetData str, , bytesTotal
MsgBox str
End Sub

Public Sub TestSocket()

If client.State = 0 Then
client.Connect
End If

If client.State <> 0 Then
MsgBox client.State
client.SendData "我是一只小鸭子~~"


Else
MsgBox "请先连接!"
End If
End Sub

Private Sub UserControl_Initialize()
client.RemoteHost = "127.0.0.1"
client.RemotePort = 8888
End Sub

然后将ocx放到另一个工程里,就可以测试了。
lizhengsq 2005-07-26
  • 打赏
  • 举报
回复
我也在做同样的问题,我觉得还是改写窗体程序,使用webclass技术更好,把窗体做成web界面

863

社区成员

发帖
与我相关
我的任务
社区描述
VB COM/DCOM/COM+
c++ 技术论坛(原bbs)
社区管理员
  • COM/DCOM/COM+社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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