Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2006-11-19
4
Medium Priority
?
146 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 400 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

715 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