• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 235
  • Last Modified:

How can I Check my application Is running from CD

I Want to enforce my app. to absolutely run from CD. How can I do that?
0
khalil_moghaddam
Asked:
khalil_moghaddam
  • 2
1 Solution
 
mokuleCommented:
What about this?

procedure TForm1.FormActivate(Sender: TObject);
begin
  if GetDriveType(PChar(ExtractFileDrive(Paramstr(0)))) <> DRIVE_CDROM then
    Close;
end;
0
 
mokuleCommented:
Or if You want to do it in an earlier application creation state.

program Project1;

uses
  Forms,Windows, Sysutils,
  Unit1 in 'Unit1.pas' {Form1};

{$R *.res}

begin
  Application.Initialize;
  if GetDriveType(PChar(ExtractFileDrive(Paramstr(0)))) <> DRIVE_CDROM then
    begin
    Application.MessageBox('You must run this program from CD','Error',MB_OK);
    end
  else
    Application.CreateForm(TForm1, Form1);
  Application.Run;
end.
0
 
khalil_moghaddamAuthor Commented:
Thanks a lot, But I think it can't recognize Virtual CD drive. Is there any way to prohibit using virtual-cd drive?
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now