• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 925
  • Last Modified:

Mapping in delphi

I used the following command to map network drives:
   WNetAddConnection('\\rsg_prod\apps1','','K:');
This would map drive K: to access rsg\prod\apps1 server

However, everybodies computer has different mapping.
I set it to a constant "K:", however, to someobody elses
computer K: might already be used.  

How do I do mapping without hard coding the drive letter?

And is there a way to retrieve what LETTER was assign
to that drive?

Thanks
0
waipahu
Asked:
waipahu
  • 2
  • 2
1 Solution
 
edeyCommented:
or using, say, z?
listening....

GL
Mike
0
 
MadshiCommented:
You can use WNetGetConnection to ask which UNC path belongs to a specific drive.
What do you mean with "mapping without hard coding the drive letter"? You mean, you want to find a "free" letter, than use this one for mapping?
Then look at the API GetLogicalDrives to find free letters...

Regards, Madshi.
0
 
waipahuAuthor Commented:
Madshi, yet i want to find the available "free" letters.
I am not sure on how to use the GetLogicalDrives.
There is also a GetLogicalDriveStrings API.
I don't know how to use either of them.
Could you show me examples of both statements?

Thanks :)
0
 
MadshiCommented:
var dw1 : dword;
    ch1 : char;
begin
  dw1 := GetLogicalDrives;
  for ch1 := 'A' to 'Z' do
    if not odd(dw1 shr (ord(ch1) - ord('A'))) then begin
      // drive [ch1]: is free
    end;

Don't know about GetLogicalDriveStrings.

Regards, Madshi.
0
 
waipahuAuthor Commented:
Thanks Madshi!!!!
Very good!!! It works

thanks
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now