Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Local Shares - Completely stuck!

Status
Not open for further replies.

davidshields

Programmer
May 15, 2002
14
GB
I'm writing an ActiveX Control for my intranet html app. So far so
good - I've sucessfully created an ocx so I'm, over 1st hurdle!

However, my control requirement is to enumarate the LOCAL shares on
this client machine.
FileSystemObject allows me to enumerate shares on mapped local drives,
so I can find out P: is mapped to \\thingy\sharename fine, but...

How do I determine what folders I am sharing from my machine - e.g. if
C:\this\that\other is share1
c:\foo\bar\baz is share2
on local hard disk c:, how do I get at these bits of info.

FWIW, I managed to determine my local machine network name, so I'm
partway there (as I want the control to expose \\machinename\sharename
to my intranet app), but how do I collate this share information in VB
?.

I thought the WNET API might help, but my brain burnt out too soon.

I know the info is available, as windows explorer shows shares with the
little hand thingy, but I'm beggared if I can see how to get at it.

PS client platform can be W98/ME/W2K, so NT/2000 only solutions are
not really useful.

Any advice / help GREATLY appreciated.

D.
 
Are you wanting to specify the share name and get the path or vice versa?

If you want to specify the share name, you can use the NetShareGetInfo API. I have an example of this that I just test (I didn't write it but it works!) Let me know if you want me to paste it here.... it's pretty lengthy, but it works.
 
I think my short answer is 'given path get share info'.

Hokay - let me go into a bit more detail, perhaps you can tell me what I should be doing !

My app (php/mysql) is a training course booking system, running on an intranet. When a course is defined, user will want to set up a set of documents that are attached to the course (joining notes, maps, blah blah blah). I use a form with file upload browse control, which produces on completion a pathname for that file. It's a multi-user, multi-client workstation app.
However, because users are dumb, they *might* point to a file say c:\this\that\other\joining.doc
So when user B goes in on a different workstation, that doc is not there.
What I want to do is examine the path returned and process it as follows:
1) its a UNC pathname \\server\share\path\path\file.doc - Fine, no action required.
2) its as above: c:\this\that\other\joining.doc and *some* part of that path is shared. (say c:\this\that shared as fredshare). Extract local machine name fredspc (I can do this bit). Walk UP the path specified until I see a bit thats shared, and build a UNC path from this, so save \\fredspc\fredshare\path\joining.doc.
3) Its as above but no part of tree is shared - warn user this is a bad move.
4) its on a mapped network drive, so see what the share is that were mapped to and substitute that. Again, I'm ok with this.

I see this as best solved with an ActiveX control, and as I don't do VC++, VB is my option.

What I *believe* I need is a tree 'walker-upper' (thankfully *much* easier than tree traversal) and a test 'is this path a share, and if so whats it called?' piece of code.

I'll look at NetShareGetInfo while you mull on this, but yes, code posting would be helpful.

So 2 things:

1) Sorry this post is so long !
2) Thanks for the offer of help, I hope the info I've given is useful.

Many Thanks, David.
 
Further Info -

Clients may be Win98, so NT specific is no good.

David.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top