Roadcrash
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(Send er: TObject);
begin
AddForm.Startup;
if (AddForm.ShowModal = mrOK) and (AddForm.Drive > #0) then
begin
>>>if pos(SymbolicLinks[AddForm. Drive], SymbolicLinks[cIndex].Driv eLetter) = 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.Driv e].DeviceP ath:=AddFo rm.txtPath .Text;
SymbolicLinks[AddForm.Driv e].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
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(Send
begin
AddForm.Startup;
if (AddForm.ShowModal = mrOK) and (AddForm.Drive > #0) then
begin
>>>if pos(SymbolicLinks[AddForm.
{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.Driv
SymbolicLinks[AddForm.Driv
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
Thanks...
Frank
ASKER
For completeness here is the procedure after I had altered the symbollink unit like Russel told me
procedure TMainForm.btnAddClick(Send er: TObject);
begin
AddForm.Startup;
if (AddForm.ShowModal = mrOK) and (AddForm.Drive > #0) then
begin
if IsVirtualPath(AddForm.txtP ath.Text) then
ShowMessage('There is little use pointing a virtual drive to a virtual drive') end
else begin
SymbolicLinks[AddForm.Driv e].DeviceP ath:=AddFo rm.txtPath .Text;
SymbolicLinks[AddForm.Driv e].Persist (True);
end;
LoadVirtualDrives;
end;
again, thank you sooo much Russel
procedure TMainForm.btnAddClick(Send
begin
AddForm.Startup;
if (AddForm.ShowModal = mrOK) and (AddForm.Drive > #0) then
begin
if IsVirtualPath(AddForm.txtP
ShowMessage('There is little use pointing a virtual drive to a virtual drive') end
else begin
SymbolicLinks[AddForm.Driv
SymbolicLinks[AddForm.Driv
end;
LoadVirtualDrives;
end;
again, thank you sooo much Russel
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