determining a network drive is disconnected[RESOLVED]
The application that I am working on is used to monitor specifric folders on a file server that is part of my home network. It looks at mounted shares for activity. Is there a way to determine that a share is not mounted???? Say a network problem occurs????
Second question.....
Currently I have shell scripts running on the remote machine that create a file when activity has occured. And my vb application looks for that file to notify me of the activity. If I wanted the vb program to do all the work. Would I errrrrr, do a directory list into an array with the time stamps of the files to be used in a compare against a last activity time that I have saved in a file?? Can I do that.... errrr, how would I populate the array with the directory listing and time stamps so that I could do my compares against it???
Dan
p.s. Ya know, the more I look at these questions the dumber I feel.
Re: determining a network drive is disconnected
Try this sample:
VB Code:
Private Const INTERNET_CONNECTION_CONFIGURED = &H40
Private Const INTERNET_CONNECTION_LAN = &H2
Private Const INTERNET_CONNECTION_MODEM = &H1
Private Const INTERNET_CONNECTION_OFFLINE = &H20
Private Const INTERNET_CONNECTION_PROXY = &H4
Private Const INTERNET_RAS_INSTALLED = &H10
Private Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef lpdwFlags As Long, ByVal dwReserved As Long) As Long
Private Sub Form_Load()
'KPD-Team 2001
'URL: [url]http://www.allapi.net/[/url]
Dim Ret As Long
Me.AutoRedraw = True
'retrieve the connection status
InternetGetConnectedState Ret, 0&
'show the result
If (Ret And INTERNET_CONNECTION_CONFIGURED) = INTERNET_CONNECTION_CONFIGURED Then Me.Print "Local system has a valid connection to the Internet, but it may or may not be currently connected."
If (Ret And INTERNET_CONNECTION_LAN) = INTERNET_CONNECTION_LAN Then Me.Print "Local system uses a local area network to connect to the Internet."
If (Ret And INTERNET_CONNECTION_MODEM) = INTERNET_CONNECTION_MODEM Then Me.Print "Local system uses a modem to connect to the Internet."
If (Ret And INTERNET_CONNECTION_OFFLINE) = INTERNET_CONNECTION_OFFLINE Then Me.Print "Local system is in offline mode."
If (Ret And INTERNET_CONNECTION_PROXY) = INTERNET_CONNECTION_PROXY Then Me.Print "Local system uses a proxy server to connect to the Internet."
If (Ret And INTERNET_RAS_INSTALLED) = INTERNET_RAS_INSTALLED Then Me.Print "Local system has RAS installed."
End Sub
Re: determining a network drive is disconnected
Ok, I looked your example up in the msdn and thnk I understand it. If I understand it correctly, the code you provided will tell me what type of internet connection I have and if its active(I think).
What I want to determine is if a local network drive is mounted prior to any futher processing. The machine running the application could be connected to the internet or local network ok, but the server machine on the local network could be down due to anything which would cause me to not have that mount.
Ping the server machine name? And interpit the results?
Is there a way via code to determine what drives the application machine has mounted? This???
VB Code:
Dim fso As New Scripting.FileSystemObject, dr As Scripting.Drive
Dim txtRemoteDrive As String
txtRemoteDrive = "Y"
Dim bolDriveMounted As Boolen
bolDriveMounted = False
for Each dr In fsoi.Drives
If dr.IsReady _
Then
If dr.DriveLetter = txtRemot4eDrive _
Then
bolDriveMounted = True
End If
Next
Shoot, if that will work. Would I use the FilesystemObject to get all files in a folder????
If I am way off on how I interpited this, please excuse my ignorance. And thank you.
Dan