Attribute VB_Name = "Module1"
'*******************************************************************
'vIDCc.dll常量和函数声明
Public Const EOK_VIDC = 0
Public Const ENAME_VIDC = (-1) '客户端名称错误
Public Const EINIT_VIDC = (-2) '初始化失败
Public Const ENULL_VIDC = (-3) '客户端对象为空
Public Const EPARAM_VIDC = (-4) '传递参数错误
Public Const ECONN_VIDC = (-5) '无法连接vIDC服务
Public Const EMAXUSER_VIDC = (-11) '无法连接vIDC服务,超过最大客户端限制
Public Const EFAILED_VIDC = (-6) 'vIDC服务返回错误
Public Const EPWD_VIDC = (-7) '密码校验错误,无法访问
Public Const EUNKNOW_VIDC = (-8) '未知的错误,可查看具体错误返回码
Public Const EBIND_VIDC = (-9) '映射端口错误
Public Const EUSED_VIDC = (-12)  '端口映射失败,指定的端口已经被占用
Public Const ESOCKINIT_VIDC = (-10) '初始化网络失败
'download by http://www.codefans.net
Public Declare Function vIDC_Init Lib "vIDCc" (ByVal clientName As String) As Long
Public Declare Function vIDC_Exit Lib "vIDCc" () As Long
Public Declare Function vIDC_Setpwd Lib "vIDCc" (ByVal strPwd As String) As Long
Public Declare Function vIDC_Connect Lib "vIDCc" (ByVal strIP As String, ByVal iPort As Integer) As Long
Public Declare Function vIDC_Close Lib "vIDCc" () As Integer
Public Declare Function vIDC_Bind Lib "vIDCc" (ByVal srcPort As Integer, ByVal strIP As String, ByVal destPort As Integer) As Long
Public Declare Function vIDC_Unbind Lib "vIDCc" (ByVal destPort As Integer) As Long
Public Declare Function vIDC_SetLogLevel Lib "vIDCc" (ByVal LogLevel As Integer) As Long
Public Declare Function vIDC_Status Lib "vIDCc" () As Long
'***************************************************************************
'获取计算机名称
'声明 GetComputerName
Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
'定义一个获取计算机名字的函数
Public Function GetCName(CName As String) As Boolean
Dim sComputerName As String ' 计算机的名字
Dim lComputerName As Long
'计算机名字的长度
Dim lResult As Long
'GetComputerName的返回值
Dim RV As Boolean
'GetCName返回值,若为TRUE则表示操作成功
lComputerNameLen = 256
sComputerName = Space(lComputerNameLen)
lResult = GetComputerName(sComputerName, lComputerNameLen)
If lResult <> 0 Then
CName = Left$(sComputerName, lComputerNameLen)
RV = True
Else
RV = False
End If
GetCName = RV
End Function