|
-
Dec 2nd, 2014, 06:50 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] How to use VB6 to detect whether one of the computer in LAN has shared folders?
In our office, all of our computers are installed with WinXP OS and situated within a same LAN. Sometimes I need to access to shared folders of other computers using Network NEIBORHOOD on the desktop, or I enter a certain path in my explorer, i.e. \\computer01\\FolderName\\
But now I want to build an application that accesses to that folder without me, doing this exact operation. Instead, I want to use a commandbutton to do the whole job. As we know, if the computer in which a folder is shared, is shut down, then it won't work. So I need to detect, beforehand, whether this folder is accessible or, in the words, the computer is running.
Besides I'm thinking of a more "advanced" functionality with which I could copy files from that shared folder.
Right now I have no clues where to begin.
-
Dec 2nd, 2014, 09:59 AM
#2
Re: How to use VB6 to detect whether one of the computer in LAN has shared folders?
Two things come to mind... make an attempt to connect to it, if it fails, move on.
The alternative is to do as Capt. Marko Ramius said "One ping only, please." -- in other words, ping the computer, if you get a reply, it's up, if you get no reply, then it's not there.
-tg
-
Dec 2nd, 2014, 08:24 PM
#3
Re: How to use VB6 to detect whether one of the computer in LAN has shared folders?
How about something like:
Code:
Option Explicit
'Ref to: Microsoft Shell Controls and Automation.
Private Shares As Collection
Private Sub EnumerateShares()
'Finds all of the file shares accessible on the network using
'the current credentials of the process.
Dim fldNetHood As Shell32.Folder
Dim itmHost As Shell32.FolderItem
Dim itmShare As Shell32.FolderItem
With New Shell32.Shell
Set fldNetHood = .NameSpace(ssfNETWORK)
End With
Set Shares = New Collection
For Each itmHost In fldNetHood.Items
If itmHost.IsFolder Then
For Each itmShare In itmHost.GetFolder.Items
If itmShare.IsFileSystem Then
Shares.Add itmShare.Path
End If
Next
End If
Next
End Sub
This will return paths valid for the local system too, but you could exclude those by host name.
-
Dec 3rd, 2014, 02:20 AM
#4
Thread Starter
Hyperactive Member
Re: How to use VB6 to detect whether one of the computer in LAN has shared folders?
I first thought it would involve some use of pretty complex WIN API related to network but Dilettante's method totally explained how I could just use the magic shell32.dll ....
However, what if I am going to add some more functionalities that can manipulate the files in that folder. Well, in this case, am I going to referrence to scrrun.dll so that I can use filesystemobject, or the OPEN method possibly, in the same way I use it in my local environment?
What if the other computer is not physical connected to the router, but rather, using wireless? And what if the other one uses WIN7 OS?
Hmm...
-
Dec 3rd, 2014, 03:11 AM
#5
Re: How to use VB6 to detect whether one of the computer in LAN has shared folders?
You can "manipulate" files in a folder using the Shell objects. No need for API calls or the slow and clunky FSO. I have no idea why anyone would go there first.
If the machines are part of the network and you have credentials for access being wireless makes no difference. However such operations over wireless connections are considered hazardous because the connections can come and go.
I have no idea why you'd think the OS matters. There can even be Linux appliances or Android tablets in the picture if they expose shares via the CIFS/SMB protocol.
-
Dec 3rd, 2014, 04:45 AM
#6
Frenzied Member
Re: How to use VB6 to detect whether one of the computer in LAN has shared folders?
I remember I did it long time ago. But I used WNetOpenEnumW and WNetEnumResourceW.
-
Dec 3rd, 2014, 04:50 AM
#7
Thread Starter
Hyperactive Member
Re: How to use VB6 to detect whether one of the computer in LAN has shared folders?
Dilettante:
Sorry that I thought too much before learning enough ... but then again, I'm learning from you!!
-
Dec 3rd, 2014, 07:20 PM
#8
Re: How to use VB6 to detect whether one of the computer in LAN has shared folders?
Take a look at Shell Objects for Scripting and Microsoft Visual Basic.
You should be able to find an earlier version of the same topic in the MSDN Library CDs that come with every legal copy of VB6.
-
Dec 3rd, 2014, 10:31 PM
#9
Thread Starter
Hyperactive Member
Re: How to use VB6 to detect whether one of the computer in LAN has shared folders?
Many thanks.
Let's consider this thread resolved.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|