局域网上的硬盘空间问题!
这个问题有点奇怪。常规的方法解决不了,向大家求救!
我现在的方法:
方法一,用api:GetDiskFreeSpaceEx
Private Declare Function GetDiskFreeSpaceEx Lib "kernel32" Alias "GetDiskFreeSpaceExA" (ByVal lpRootPathName As String, lpFreeBytesAvailableToCaller As Currency, lpTotalNumberOfBytes As Currency, lpTotalNumberOfFreeBytes As Currency) As Long
Private Sub Form_Load()
Dim r As Long, BytesFreeToCalller As Currency, TotalBytes As Currency
Dim TotalFreeBytes As Currency, TotalBytesUsed As Currency
'the drive to find
Const RootPathName = "\\192.168.100.89\C$\"
'get the drive's disk parameters
Call GetDiskFreeSpaceEx(RootPathName, BytesFreeToCalller, TotalBytes, TotalFreeBytes)
'show the results, multiplying the returned
'value by 10000 to adjust for the 4 decimal
'places that the currency data type returns.
Me.AutoRedraw = True
Me.Cls
Me.Print
Me.Print " C£ºÅÌ×ܿռä:", Format$(TotalBytes * 10000 / 1024 / 1024, "###,###,###,##0") & " M bytes"
Me.Print " C£ºÅÌÊ£Óà¿Õ¼ä:", Format$(TotalFreeBytes * 10000 / 1024 / 1024, "###,###,###,##0") & " M bytes"
Me.Print " C£ºÅÌ×Ü¿ÉÓÿռä:", Format$(BytesFreeToCalller * 10000 / 1024 / 1024, "###,###,###,##0") & " M bytes"
Me.Print " C£ºÅÌÒÑÓÿռä :", Format$((TotalBytes - TotalFreeBytes) * 10000 / 1024 / 1024, "###,###,###,##0") & " M bytes"
End Sub
方法二:用fso
Dim MyFSO As Scripting.FileSystemObject
Private Sub Command1_Click()
MsgBox MyFSO.GetDriveName("\\192.168.100.89\c$")
MsgBox MyFSO.GetDrive(MyFSO.GetDriveName("\\192.168.100.89\c:"))
MsgBox MyFSO.GetDrive(MyFSO.GetDriveName("\\192.168.100.89\c$")).FreeSpace
End Sub
Private Sub Form_Load()
Set MyFSO = New FileSystemObject
End Sub
这两种方法在我的计算机上用都可以成功,但是换一台试就得不到结果。两台计算机的权限是一样的。
对于第二种方法出的错误是“找不到路径”
望高手们给点提示?问题出在哪里?
我不知道问题有没有描述清楚,如不清楚,msn在线blueiceblue@hotmail.com