Search code examples
c++buildershellexecute

Use ShellExecute to browse to a \\location


I use C++ with Borland C++ Builder and I am able to browse to a local or remote folder using the following code:

  AnsiString sDir = "C:\\Temp";
  ShellExecute(Application->Handle,"OPEN", "EXPLORER.EXE", sDir.c_str(), NULL, 1);

But if I try to access a folder on a remote computer that starts with two backslashes, such as "\\mypath", the above code does not work anymore. Is there a way to convince Windows Explorer open "\\mypath"?


Solution

  • I tried again the code I provided and in fact it works:

    AnsiString sDir = "\\\\computername\\myfolder";
    ShellExecute(Application->Handle,"OPEN", "EXPLORER.EXE", sDir.c_str(), NULL, 1);
    

    I am not sure why it didn't work for me before (at one stage I probably forgot to use two backslashes in the path before myfolder, although I also tried accessing just computername). Sorry for wasting your time.

    Nick