'取得命令行参数
应该是这个形式:FastCopy.exe
's的返回值是
网络目录名,文件名
如:“\\liang\,myadd.exe"
'然后为了区烂备分开目录名和文件名,就查销衡找","号
p=instr(1,s,",")
'如果找到饥斗毁就分别取“,”前面的目录和后面的应用程序名。
可以在服务器端放2个文件,一个假如是Update.ini,还有一个就是你的程序,假如是,在本地还要有一个文件,存放设置,假如是config.iniUpdate.ini:
[update]
new=1.0.1
config.ini:
[config]
ver=1.0.0
代码:
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Private 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
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Private Sub Form_Load()
r = URLDownloadToFile(0,"", App.Path &"\Update\u.ini", 0, 0)
'下载好文件后,就开始读ini了
Dim ret As Long
Dim nowv, newv As String
nowv = Space$(1000) '事先定义读取值的字串宽度
'读出新版本和旧版本
ret = GetPrivateProfileString("update", "new", ""猜森, newv, 1000, App.Path &"\Update\Update.ini")
ret = GetPrivateProfileString("config", "ver", "", nowv, 1000, App.Path &"\Update\Update.ini")
'如果新版本和旧版本不同,则开始下载新版本
If nowv <>newv Then
r = URLDownloadToFile(0,"", App.Path &"\Update\1.exe", 0, 0)
End Sub
写了这么多,楼主是不是给点喊携分,多给点
一楼说文件类型,显然是没有看穗渗亩题
看到二楼说的,我无语~~
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)