Solved

Accessing a: drive

Posted on 2000-04-02
14
202 Views
Last Modified: 2010-04-04
Hello,
How do I access drive a: or CDROM
drive and then automatically erase
files on that selected drive using
Delphi 5.
........................................
Ignore above I will rephrase question...
Senario: From a menu item I basically would need to wipe a disk
automatically...a Floppy in drive a:\ is a good example.
Please note by using filedelete()you have to know which files
are on disk and indivdually delete them.I would need an automated
approach.(Delete all files on drive a:).


regards,
frank
0
Comment
Question by:frw
  • 3
  • 2
  • 2
  • +6
14 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 2678132
Erase files from CDROM????

Besides, I do not quite understand your question.
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2678135
To delete files you can use this:

DeleteFile('A:\somefile.xxx');
0
 
LVL 17

Expert Comment

by:inthe
ID: 2678148
for a drive do exactly same as normal drive ..

deletefile(a:\somefilename.file)

you cant erase a file on cdrom unless you mean you have it formatted as a drive (like with easycd creator etc?)
0
 
LVL 17

Expert Comment

by:inthe
ID: 2678149
;-)
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2678165
(o:
0
 

Author Comment

by:frw
ID: 2678485
Edited text of question.
0
 
LVL 15

Expert Comment

by:simonet
ID: 2678583
You have to do an interaction through all files in the disk in order to wipe the disk clean.

There are no functions in Delphi that will allow you to create a clean FAT on a floppy. You can use INT 21h functions, but that's a whole lotta trouble, and not sure to work with NT.

The best approach is to find all files on the disk, delete them as they are found. Then delete all directories and their parents, etc. Some interaction or recursion will be necessary here.

Yours,

Alex

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Accepted Solution

by:
nrico earned 100 total points
ID: 2679314
simonet is right. I'll work it our for you... :-)

Function SlashDir(Name:String):String;
Begin
  If Name[Length(Name)]<>'\' Then Name:=Name+'\';
  SlashDir:=Name;
End;

Procedure WipeDir(Name:String);
Var
  S:TSearchRec;
  Result:Integer;
Begin
  Name:=SlashDir(Name);
  Result:=FindFirst(Name+'*.*',faAnyFile,S);
  While Result=0 Do
  Begin
    If (S.Attr Or faDirectory>0) And (S.Name[1]<>'.') Then WipeDir(Name+S.Name)
      Else DeleteFile(Name+S.Name);
    Result:=FindNext(S);
  End;
  FindClose(S);
  {$I-}
  RmDir(Name);
  {$I+}
End;

This could contain some minor bugs (Like I'm not sure about the TSearchRec.Attr member), but it should mostly be working.
0
 
LVL 9

Expert Comment

by:ITugay
ID: 2679456
uses ... ShellAPI;

.....
ShellExecute(handle,'open','command','/c DEL A:\YOURFILE.EXT',nil,0);
ShellExecute(handle,'open','command','/c DEL A:\*.EXE',nil,0);
....
--------
Igor.
0
 

Expert Comment

by:johnstoned
ID: 2679500
nrico's answer is the way i'd do it, but I think you need to change

If (S.Attr Or faDirectory>0) And (S.Name[1]<>'.') Then WipeDir(Name+S.Name)
      Else DeleteFile(Name+S.Name);


to

If (S.Attr and faDirectory>0) And (S.Name[1]<>'.') Then WipeDir(Name+S.Name)
      Else DeleteFile(Name+S.Name);

This will detect directories properly now.

Dave.
     
   
0
 
LVL 2

Expert Comment

by:mullet_attack
ID: 2680701
You also need to change :

If (S.Attr and faDirectory>0) And (S.Name[1]<>'.') Then WipeDir(Name+S.Name)
      Else DeleteFile(Name+S.Name);

to

If (S.Attr and faDirectory>0) And (S.Name[1]<>'.') and (S.Name[1]<>'..') Then WipeDir(Name+S.Name)
      Else DeleteFile(Name+S.Name);


This will detect the parent directory when you are in a subdirectory.

0
 
LVL 1

Expert Comment

by:titz
ID: 2681128
hi,

i think the best and simplest way is to format the disc !

cheers
titz
0
 

Author Comment

by:frw
ID: 2682014
Thanks to all who got involved with
this question.
Frank
0
 
LVL 15

Expert Comment

by:simonet
ID: 2682534
Well, you're welcome.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now