?
Solved

Floppydisk in floppydrive?

Posted on 2003-02-27
2
Medium Priority
?
145 Views
Last Modified: 2010-04-04
How do I find when there is a floppydisk in the floppydrive???? I tried something like:

function FloppyInFloppyDrive:boolean;
begin
  result:=not Diskfree(0)=-1;
end;

But Windows comes up with at dialogbox which says "Insert disk" - OK, CANCEL ect.

Any ideess?
0
Comment
Question by:hutelihut
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Expert Comment

by:Codeslave
ID: 8038510
// try the following on a form with a Tlabel and a TButton.
// It is adapted from a code snippet from GExperts.

procedure TForm1.Button1Click(Sender: TObject);
var
  ErrorMode : Word;
begin
  ErrorMode := SetErrorMode(SEM_FAILCRITICALERRORS);
  try
    { Check for drive here }
    if DiskFree(1) = -1 then
      Label1.Caption := 'Not Installed'
    else
      Label1.Caption := 'Disk Installed';
  finally
    SetErrorMode(ErrorMode);
  end;
end;

0
 
LVL 9

Accepted Solution

by:
ginsonic earned 200 total points
ID: 8039755
function DiskInDrive(Drive: Char): Boolean;
var ErrorMode: word;
begin
  if Drive in ['a'..'z'] then Dec(Drive, $20);
  if not (Drive in ['A'..'Z']) then
    raise EConvertError.Create('Not a valid drive ID');
  ErrorMode := SetErrorMode(SEM_FailCriticalErrors);
  try
    if DiskSize(Ord(Drive) - $40) = -1 then
      Result := False
    else
      Result := True;
  finally
    SetErrorMode(ErrorMode);
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var DriveStr : String;
begin
 DriveStr := 'a:\';
 If DiskInDrive(DriveStr[1]) Then
  ShowMessage('There is a disk in Drive ' + AnsiUpperCase(DriveStr[1]))
   Else
  ShowMessage('Drive ' + AnsiUpperCase(DriveStr[1]) + ' has no disk')
end;
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month12 days, 18 hours left to enroll

777 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