Solved

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

Posted on 2006-11-19
4
143 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Include multiple hostnames in this command? 3 55
fizzArray  challenge 1 109
has77  challenge 9 97
how to use laptop or pad camera in vb.net windows application 2 103
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
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…

763 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