Solved

How can I Check my application Is running from CD

Posted on 2004-04-04
3
227 Views
Last Modified: 2010-04-05
I Want to enforce my app. to absolutely run from CD. How can I do that?
0
Comment
Question by:khalil_moghaddam
  • 2
3 Comments
 
LVL 17

Accepted Solution

by:
mokule earned 50 total points
ID: 10751373
What about this?

procedure TForm1.FormActivate(Sender: TObject);
begin
  if GetDriveType(PChar(ExtractFileDrive(Paramstr(0)))) <> DRIVE_CDROM then
    Close;
end;
0
 
LVL 17

Expert Comment

by:mokule
ID: 10751393
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
 
LVL 1

Author Comment

by:khalil_moghaddam
ID: 10754936
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Question has a verified solution.

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

Suggested Solutions

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…
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

821 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