We help IT Professionals succeed at work.

How to get device's share name

mazzini
mazzini asked
on
On Windows 98, how can I get the share name of my local hard drive?
Comment
Watch Question

Commented:
Quick and Dirty:


var DriveName:array[0..255] of char;
begin
  QueryDosDevice('F:',Drivename,255);//F is shared drive
  ShowMessage(DriveName);
end;


Good luck!!

Commented:
Haven't looked into it yet, but perhaps this usenet article has what you're looking for?

GL
Mike

Author

Commented:
I've tried with the QueryDosDevice function, but it only returns the unit name. I need to send the DOS unit ('C:', 'D:', etc) and receive the network sharing name ('\\MAZZINI\C', etc.). With remote devices mapped in my local system things are easy: just need to use ExpandUNCFileName to obtain the network sharing name. But if you have a local drive, ExpandUNCFileName doesn't expands the name, and you remain with, say, 'C:\WINDOWS'.

Mazzini

Commented:
One solution would be to use NetShareEnum, but the parameters in win9x are different from the APIs in winNT. I've wrapped this stuff up in my package madSecurity (free for non-commercial usage). With this package you could e.g. do this:

with Shares([stDisk], 'C:\') do
  for i := 0 to ItemCount - 1 do
    ShowMessage(Items[i].NetName);

This lists all shares on your local drive C:\ (there can be more than 1 in win9x, too).

Maybe WNetEnumResource also works, don't know.

Regards, Madshi.

www.madshi.net
Commented:
Ah, Madshi the Great & Powerfull strikes again! :), Seriously I'd sugest looking at his stuff.

GL
Mike

ps-  Ooops! just noticed I had forgot to actuall provide the link in my earlier comment. Here it is: http://groups.google.com/groups?hl=en&threadm=6jtuop%24p6e2%40forums.borland.com&rnum=20&prev=/groups%3Fq%3Ddelphi%2Bshare%2Bdisk%2Bname%26hl%3Den%26start%3D10%26sa%3DN

Commented:
Thanx Mike...  :-)  The usenet article looks ok, though. Haven't tested it, but it uses the right APIs at least...

Commented:
Listening...

Author

Commented:
I'm trying Mike's sugestion. Seems to be in the right way ... :-)

Mazzini

Author

Commented:
Yeah! It's exactly what I was looking for! Now I can create an array of local sharing resources and their network names.

Thanks for the help.

Mazzini

Commented:
Glad to be of service :)

GL
Mike

Explore More ContentExplore courses, solutions, and other research materials related to this topic.