Solved

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

Posted on 2006-11-19
4
137 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
Comment Utility
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
Comment Utility
I'll try and let you know if it worked out well with me
Thanks
0
 

Author Comment

by:khlauster
Comment Utility
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
Comment Utility
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 improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

762 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

7 Experts available now in Live!

Get 1:1 Help Now