求助:vb中winsock客户端服务器端连接问题
把代码发上来`
定义connect和accept吗
'这个不需要,如果客户端发送连接请求,如果是点对点通讯的话可以直接在CONNECTIONREQUEST事件中ACCEPT REQUESTID
Private Sub Winsock1_ConnectionRequest( ByVal requestID As Long)
Winsock1accept requestID
end sub
VB无法执行ASP代码,最多执行其中的SCRIPT代码,如果ASP文件是纯SCRIPT可以在VB中调用vb script对象。
代替的思路,是在你的VB中做个INET控件(Microsoft Internet Transfer Controls),用这个控件访问客户端指定的要访问的服务器端ASP文件,这样INET就可获得服务器运行完返回的结果,你再在VB中将这个从INET中得到的结果返回给客户端。如果是要直接显示结果,可以直接用WebBrower控件(Microsoft Internet Controls)。
tcp/ socket 网络编程,在运行程序的时候,就已经判断是否连接
如果是数据库编程,可以用ping 服务器的IP,用返回的值来判断是否连接
不过我用vbnet 2013
我建议改名按照以下定义
修正文件夹字符串
path=文件的路径
filepath=replace(path,":","")
filepath=replace(filepath,"\","|")
fname=文件名
fnametmp=split(fname,"")
filesplit=ubound(fnametmp)
fname=fnametmp(0)
for i=1 to filesplit -1
fname=fname & "" & fnametmp(i)
next
fname=fname & "" & filepath & "" & fnametmp(filesplit)
文件格式=旧文件名路径文件扩展名
不知道你要怎么保存到服务器,最简单的方法当然是映射磁盘,直接使用filecopy命令复制过去
如果需要恢复,按照上边的方法逆向操作就可以了
上边只是一点想法,是否实用没研究过,献丑了
将以下代码保存到模块中:
Declare Function GetPrivateProfileString Lib "kernel32" Alias _
"GetPrivateProfileStringA" (ByVal lpApplicationName As String, _
ByVal lpKeyName As Any, _
ByVal lpDefault As String, _
ByVal lpReturnedString As String, _
ByVal nSize As Long, _
ByVal lpFileName As String) As Long
Declare Function WritePrivateProfileStringByKeyName& Lib "kernel32" Alias _
"WritePrivateProfileStringA" (ByVal lpApplicationName As String, _
ByVal lpKeyName As String, _
ByVal lpString As String, _
Public Function GetIniParam(NomFichier As String, NomSection As String, NomVariable As String) As String
Dim ReadString As String 255
Dim returnv As String
Dim mResultLen As Integer
mResultLen = GetPrivateProfileString(NomSection, NomVariable, "(Unassigned)", ReadString, Len(ReadString) - 1, NomFichier)
If IsNull(ReadString) Or Left$(ReadString, 12) = "(Unassigned)" Then
Dim Tempvalue As Variant
Dim Message As String
Message = "配置文件 " & NomFichier & " 不存在"
returnv = ""
Else
returnv = Left$(ReadString, InStr(ReadString, Chr$(0)) - 1)
End If
GetIniParam = returnv
End Function
Public Function WriteWinIniParam(NomDuIni As String, sLaSection As String, sNouvelleCle As String, sNouvelleValeur As String)
Dim iSucccess As Integer
iSucccess = WritePrivateProfileStringByKeyName(sLaSection, sNouvelleCle, sNouvelleValeur, NomDuIni)
If iSucccess = 0 Then
WriteWinIniParam = False
Else
WriteWinIniParam = True
End If
End Function
调用方法:
Call WriteWinIniParam(AppPath & "\LiveUpdateini", "LiveUpdate", "AppName", txtAppNameText)
txtFileText = GetIniParam(AppPath & "\LiveUpdateini", "LiveUpdate", "FILES1")
0条评论