How to determine a mapped network drive path within a PowerBuilder application

Symptom

Customer wished to determine the full server path to a mapped network drive

Environment

  • Microsoft Windows 7 x64

  • PowerBuilder

Solution

The following steps allow you to determine the path for a mapped network drive from within a PowerBuilder application:

  • The full path of a mapped drive is stored in the registry. Let us take M: as an example drive.

  • Run regedit and go to HKEY_CURRENT_USER\Network

  • Look for RemotePath under M entry which is the full path to the mapped network drive:


    This value can be retrieved in a PowerBuilder application using the following PowerScript:

    string ls_mapped_drive = "M"
    string ls_remotepath
    RegistryGet("HKEY_CURRENT_USER\Network\" + ls_mapped_drive, "RemotePath", RegString!, ls_remotepath)
    where ls_remotepath will contain the remotepath to the drive.