Options

Convert Mapped drive to UNC

ara3nara3n Member Posts: 9,256
Hello
Has anybody done a modification to take a mapped drive and change the value to UNC path when the user selects a file?

Currently need this when user selects a recordlink.
Ahmed Rashed Amini
Independent Consultant/Developer


blog: https://dynamicsuser.net/nav/b/ara3n

Comments

  • Options
    Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
  • Options
    ara3nara3n Member Posts: 9,256
    it uses a dll file "mpr.dll" and i need it in classic. as well as rtc.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    vaprogvaprog Member Posts: 1,125
    This solution uses WSH:
    PROCEDURE GetUNCPath(SrcPath : Text[260]) UNCPath : Text[1024];
        VAR
          fso : Automation 'Windows Script Host Object Model'.FileSystemObject";
          oDrive : Automation 'Windows Script Host Object Model'.Drive";
          v : Variant;
          DriveType : Integer;
        BEGIN
          IF SrcPath = '' THEN EXIT(SrcPath);
          IF ISCLEAR(fso) THEN CREATE(fso);
          UNCPath := fso.GetAbsolutePathName(SrcPath);
          oDrive := fso.GetDrive(fso.GetDriveName(UNCPath));
          v := oDrive.DriveType;
          IF v.ISINTEGER THEN
            DriveType := oDrive.DriveType
          ELSE
            DriveType := 0;
    
          IF (DriveType = 3) AND (UNCPath[2] = ':') THEN // network path w/ drive letter
            UNCPath := oDrive.ShareName + COPYSTR(UNCPath,3);
        END;
    
    This code also extends a relative path to an absolut one.
  • Options
    ProcatProcat Member Posts: 31
    Can this be used in some modified form?
    Name	DataType	Subtype	Length
    File	Automation	'Microsoft Scripting Runtime'.FileSystemObject	
    Drive	Automation	'Microsoft Scripting Runtime'.Drive	
    
    CREATE(File);
    Drive := File.GetDrive('H:\');
    MESSAGE(Drive.ShareName);
    
Sign In or Register to comment.