robbiegrove
asked on
Get share location from mapped drive letter
Just a quick question, how do I get the share location via Windows API by providing the drive letter?
This needs to work on all 9x and NTx Windows OS'
e.g: G: is mapped to \\mymachine\shares\somethi ng\photos, I want to get \\mymachine\shares\somethi ng\photos from the windows API by specfying G:
Thanks in advance
Robbie
This needs to work on all 9x and NTx Windows OS'
e.g: G: is mapped to \\mymachine\shares\somethi
Thanks in advance
Robbie
ASKER
Errr I think you misunderstood the question mate..
I want the share location/path of a mapped drive letter.
E.g. simple example should be something along the lines of GetSharePath('G:') should return '\\mymachine\shares\someth ing\photos '
I want the share location/path of a mapped drive letter.
E.g. simple example should be something along the lines of GetSharePath('G:') should return '\\mymachine\shares\someth
Try using ExpandUNCFileName(strFileO rFolderNam e)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Very nice... :-)
And if you are looking at Windows 95 compatibility you can type out the rest of the GetUniversalName function in the SysUtils uit.. :-)
Bedouin..
And if you are looking at Windows 95 compatibility you can type out the rest of the GetUniversalName function in the SysUtils uit.. :-)
Bedouin..
ASKER
Sun4Sunday's GetUNC() answer accepted :)
Thanks guys
Thanks guys
uses ShellAPI;
var
opInfo : _SHFILEOPSTRUCT;
begin
opInfo.pFrom := '\\mymachine\shares\someth
// opInfo.pFrom := 'G:\shared folder name'; //you can set the like this also
opInfo.pTo := 'C:\Destination'; //DestinationFolder
opInfo.wFunc := FO_COPY; //Copy it
opInfo.fFlags := FOF_NOCONFIRMATION or //no confirmation Respond with "Yes to All" for any dialog box that is displayed.
FOF_NOCONFIRMMKDIR or //no confirmation Do not confirm the creation of a new directory if the operation requires one to be created.
//FOF_FILESONLY or //Perform the operation on files only if a wildcard file name (*.*) is specified
//FOF_RENAMEONCOLLISION or //rename if dest exist
//FOF_NOERRORUI or Do not display a user interface if an error occurs.
FOF_SIMPLEPROGRESS; //show a progress
opInfo.hNameMappings := nil; // no mappings
opInfo.fAnyOperationsAbort
opInfo.lpszProgressTitle := 'Moving . . .'; //foo simpleprogressdisplay
opInfo.Wnd := self.handle; //the parent of the progressdisplay
SHFileOperation(opInfo); //do it
if SHFileOperation(opInfo) <> 0 then RaiseLastOSError;
end;
//------------------------
The above code works well to copy the entire folder.
Keep an eye on this https://www.experts-exchange.com/questions/21666726/Only-copy-jpg-from-a-folder.html
Make sure that the mapped drive is set to reconnect always.
sun4sunday