Link to home
Start Free TrialLog in
Avatar of Roadcrash
RoadcrashFlag for Netherlands

asked on

Question regarding the Symbollink Unit created by Rlibby for the virtual drive manager

Hi

Im working with the virtual drive manager, for the most part created by and maintained by the symbollink unit, and I am trying to prevent the following situation, since this situation does not seem logical or of any use, but can be done

Someone can add a new drive, which points to a virtual drive, this does not seem to cause problems, but I cannot find any use for this, so Im trying to prevent this from being done, by comparing the new drive letter to the strings which represent the present and current virtual drives

procedure TMainForm.btnAddClick(Sender: TObject);
begin

  AddForm.Startup;
  if (AddForm.ShowModal = mrOK) and (AddForm.Drive > #0) then
  begin
   
>>>if pos(SymbolicLinks[AddForm.Drive], SymbolicLinks[cIndex].DriveLetter) = 0 then
{where the first is the new drive we are trying to add, and the second should be the list of the present virtual drives}

     SymbolicLinks[AddForm.Drive].DevicePath:=AddForm.txtPath.Text;
     SymbolicLinks[AddForm.Drive].Persist(True);
  end;
  LoadVirtualDrives;

end;

I have looked through the symbollink unit, but really cannot make much sense of it, at least not so much that i can perform the comparison, the above code fails and i know why, im comparing different types, plus i need to declare a variable [i think?] but since i even do not know if im comparing the right things i got stuck here

Frank
Avatar of Russell Libby
Russell Libby
Flag of United States of America image

Frank,

You just need to check the new path being added to get the drive letter, eg:

path = "X:\system32" // eg X was mapped to "c:\windows"

drive would be "X". And check to see if that drive maps to a path by using IsPath, eg:

if SymbolicLinks['X'].IsPath then
 // Dont allow a mapping to it

If IsPath is false, then its a real device or it hasn't been mapped. If you need an example let me know.

Regards,
Russell


 
ASKER CERTIFIED SOLUTION
Avatar of Russell Libby
Russell Libby
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Roadcrash

ASKER

Hey Russel perfect, I wonder why Borland has not hired you yet for writing their helpfiles lol, they could use your help Im sure of that haha

Thanks...


Frank
For completeness here is the procedure after I had altered the symbollink unit like Russel told me

procedure TMainForm.btnAddClick(Sender: TObject);
begin

  AddForm.Startup;
  if (AddForm.ShowModal = mrOK) and (AddForm.Drive > #0) then
    begin
      if IsVirtualPath(AddForm.txtPath.Text) then
      ShowMessage('There is little use pointing a virtual drive to a virtual drive') end
      else begin
    SymbolicLinks[AddForm.Drive].DevicePath:=AddForm.txtPath.Text;
     SymbolicLinks[AddForm.Drive].Persist(True);
     end;
 
  LoadVirtualDrives;

end;

again, thank you sooo much Russel