[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1482
  • Last Modified:

Convert a local path to UNC in Delphi

How can I convert a local path to a UNC path, using existing share names?
0
phyyl
Asked:
phyyl
  • 2
  • 2
1 Solution
 
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:
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
 
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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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