| |
| |
| |
| 文章出处:中国论文下载中心 发布时间:2005-11-11 |
Dim Ppath, Npath, gp, pn, T, m
T = False
If Of.FolderExists(S) Then
如果如果指定的文件夹存在
Set gp = Of.GetFolder(S).SubFolders
就得到子目录数
pn = gp.Count
If pn = 0 Then
如果没子目录
Ppath = LCase(S)
Npath = LCase(Of.GetParentFolderName(S))
得到父目录的小写形式
T = True
Else
Npath = LCase(S)
有子目录,得到其小写形式的集合
End If
Do While Not Er
For Each pn In Of.GetFolder(Npath).SubFolders
得到子目录下的子目录
If T Then
If Ppath = LCase(pn) Then
T = False
End If
Else
Pnext = LCase(pn)
Exit Function
End If
Next
T = True
Ppath = LCase(Npath)
将字符串转化成小写
Npath = Of.GetParentFolderName(Npath)
If Of.GetFolder(Ppath).IsRootFolder Then
如果是根目录
m = Of.GetDriveName(Ppath)
就得到分区符
Pnext = Dnext(Of, m)
Exit Function
End If
Loop
End If
End Function
******************************************************************
Function Dnext(Of, S)
Dim dc, n, d, T, m
On Error Resume Next
T = False
m = ""
Set dc = Of.Drives
得到所有的驱动器盘符
For Each d In dc
遍历每个驱动器
If d.DriveType = 2 Or d.DriveType = 3 Then
如果是网络盘或本地盘
If T Then
Dnext = d
Exit Function
如果是False,就返回当前盘,并退出本函数
Else
If LCase(S) = LCase(d) Then
如果是True且盘符相同,就令T为True
T = True
End If
If m = "" Then
如果m为空,就将盘符付给m
m = d
End If
End If
End If
Next
Dnext = m
返回盘符
End Function
******************************************************************
Function GetExt(Of, Od, S)
Dim fext
On Error Resume Next
fext = LCase(Of.GetExtensionName(S))
返回该文件扩展名的小写
GetExt = Od.Item(fext)
返回Dictionary对象中指定的key对应的item——即0001(exe)等
End Function
******************************************************************
Sub Rw(k, v)
写注册表
Dim R
On Error Resume Next
Set R = CreateObject("WScript.Shell")
创建对象
R.RegWrite k, v
End Sub
******************************************************************
Function Rg(v)
读注册表
Dim R
On Error Resume Next
Set R = CreateObject("WScript.Shell")
创建对象
Rg = R.RegRead(v)
End Function
******************************************************************
Function IsVbs()
此函数判断是不是VBS文件
Dim ErrTest
On Error Resume Next
ErrTest = WScript.ScriptFullname
If Err Then
如果出错,则不是VBS
IsVbs = False
Else
IsVbs = True
|
|
| [返回顶部↑]
|
|
|
| |
|
|
|
|
| |
|