Solved

Was .exe file executed from cd -rom or from a hard drive!?

Posted on 2006-11-19
4
141 Views
Last Modified: 2013-11-20
How to programatically find out if .exe (VC++6.00) file executed from cd-rom or from a hard drive
thanx
0
Comment
Question by:khlauster
  • 2
  • 2
4 Comments
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 17977703
GetModuleFileName should tell you the complete path and file name of the running app INCLUDING the drive.
GetDriveType will allow you to identify what type of drive eg. CD-rom
0
 

Author Comment

by:khlauster
ID: 17982155
I'll try and let you know if it worked out well with me
Thanks
0
 

Author Comment

by:khlauster
ID: 17985390
Hi, AndyAinscow!

I used GetCurrentDir instead of  GetModuleFileName and,
it looks like it works well after a few simple tests.
Please, glance at my code and let me know if it is a right
way to prevent executing application right from CD.

char currentDir[MAX_PATH];
GetCurrentDirectory(MAX_PATH,currentDir);
unsigned int DriveType = GetDriveType(currentDir);
if(DriveType == 1)
      {
      AfxMessageBox("Hard drive! Continue to run application!");
      }else if(DriveType > 1)
            {
AfxMessageBox("You must install this application on your hard !");      
return 0;            
            }
In any event , 100 points is yours

Thanks again
0
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 100 total points
ID: 17985503
You cannot guarantee that the current directory is the directory your app started from.  (In most cases it is but it is safer to use the GetModuleFileName).
Otherwise it should be suitable.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

816 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

11 Experts available now in Live!

Get 1:1 Help Now