Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 238
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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