Convert a local path to UNC in Delphi

How can I convert a local path to a UNC path, using existing share names?
phyylAsked:
Who is Participating?
 
Ustin19Connect With a Mentor Commented:
replace c:\ to c$\ and use 2 functions below:
Function GetCompName:string;
 var
 i:DWORD;
 p:PChar;
begin
 i:=255;
 GetMem(p, i);
 GetComputerName(p, i);
 Result:=String(p);
 FreeMem(p);
end;
 
Function BuildRemotePath(comp,path:String):String;
Begin
 Result:='\\'+comp+'\'+Modify(path,':','$')
End;

Open in new window

0
 
JohnjcesCommented:
It would be the same... i.e.:

\\LocalComputerName\ShareName

just like it would be for a remote PC

\\RemotePCName\ShareName

OR to make your Q clearer, do you want to convert

C:\SomeDirectory\MySharedDirectory

to

\\LocalPCName\ShareName

??

John
0
 
Ustin19Commented:
Modify() is function, which replaces any entries of : to $
0
 
JohnjcesCommented:
Points should be split.
0
 
Vee_ModCommented:
All,
 
Following an 'Objection' by Johnjces (at http://www.experts-exchange.com/Q_26673614.html) to the intended closure of this question, it has been reviewed by at least two Moderators and is being closed as recommended by the Cleanup Volunteer.
 
At this point I am going to re-start the auto-close procedure.
 
Thank you,
 
Vee_Mod
Community Support Moderator
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.