Solved

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

Posted on 2006-11-19
4
145 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
[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
  • 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

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

623 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