使用MSWinsockLib.Winsock对象后的程序,打包时,如何把这个对象加入进去??

Tongls 2005-05-17 04:01:07
最近写了一个FTP下载的程序,在本机上可以使用。但是在别的电脑上就是不能使用。一用就产生436号错误,即创建ActiveX控件不能创建对象。

我的安装包已经把MsWinsock.ocx打包进去了。但是还是不能使用。

真是气死了,希望高手帮忙一下。
...全文
172 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Tongls 2005-05-18
  • 打赏
  • 举报
回复
我就使用了MSWinsockLib.Winsock这个对象。

在别的电脑上就是不能创建这个对象。真是不知道为什么???????????
Tongls 2005-05-18
  • 打赏
  • 举报
回复
The error occurs because the target computer is missing the license information for the control objects that are used in the application. You might attempt to set the project reference to point to MSWINSCK.ocx, and then generate a deployment package through the use of the Package and Deployment Wizard. This would generate a setup package that contains the correct version of the Winsock control. However, the license key for the control will not be compiled into the application unless an instance of the control is placed on a form. When you try to instantiate the objects at run time, the application has no way to provide the license key, and the code will fail. For example, the following code will run properly at design time, but will fail at run time on computers that do not have Visual Basic installed:

程序原来是这样定义的。
Dim myWinSock As MSWinsockLib.Winsock

Sub Main()
' Early binding does not work
Set myWinSock = New MSWinsockLib.Winsock

myWinSock.LocalPort = 5432

myWinSock.Listen

MsgBox ("Listening!")

myWinSock.Close
End Sub


Therefore, you must provide an instance of the Winsock control on a form so that Visual Basic can compile the license information into the application. You can make the form hidden if necessary. To do this, set the form's Visible property to "False." You can then prepare for deployment. The following code snippet demonstrates the method:



使用这种方法,就解决了问题。
Dim myWinsock As MSWinsockLib.Winsock

Sub Main()
' Form1 is hidden
Set myWinsock = Form1.myWinsock

myWinsock.LocalPort = 5432

myWinsock.Listen

MsgBox ("Listening!")

myWinsock.Close
End Sub

谢谢各位的回答。
ljhuahua 2005-05-17
  • 打赏
  • 举报
回复
是不是在你的程序里引用了的DLL文件,这些文件是需要在别的机器上用注册的。
Tongls 2005-05-17
  • 打赏
  • 举报
回复
使用VB的打包程序也是一样的,没有用。
zyg0 2005-05-17
  • 打赏
  • 举报
回复
用vb的打包程序打包一下看看,有可能是打包了没注册

1,502

社区成员

发帖
与我相关
我的任务
社区描述
VB 网络编程
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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