The MASM Forum

General => The Campus => Topic started by: Farabi on December 20, 2012, 10:10:25 AM

Title: Run on a CD Drive
Post by: Farabi on December 20, 2012, 10:10:25 AM
How to know if our software were run on a CD Drive not on a harddrive?
Title: Re: Run on a CD Drive
Post by: dedndave on December 20, 2012, 10:19:14 AM
well - if you write files, like INI files to the current folder, it won't work
use standard folders like C:\Documents and Settings\<USER>\Application Data
(see the Recycle Bin thread - Jochen was playing with code to retrieve those folder names)

the other thing that can cause programs to not be "portable" is their absence when the CD is removed
it should not cause the OS to look for something that isn't there
Title: Re: Run on a CD Drive
Post by: dedndave on December 20, 2012, 10:35:55 AM
oh...
and don't make any assumptions about the location of your program and its' files
it may be in D:\ one time it is run and E:\SomeFolder\ the next time
don't store that location in your config files because it may not work next time   :P
Title: Re: Run on a CD Drive
Post by: Tedd on December 21, 2012, 03:14:30 AM
GetModuleFileName with NULL, then check the return value of GetDriveType.
Title: Re: Run on a CD Drive
Post by: Farabi on December 21, 2012, 10:48:32 AM
Quote from: Tedd on December 21, 2012, 03:14:30 AM
GetModuleFileName with NULL, then check the return value of GetDriveType.

Thanks it is worked. Do you know how to know the CD ROM name?
Title: Re: Run on a CD Drive
Post by: dedndave on December 21, 2012, 11:11:40 AM
GetVolumeInformation
http://msdn.microsoft.com/en-us/library/windows/desktop/aa364993%28v=vs.85%29.aspx (http://msdn.microsoft.com/en-us/library/windows/desktop/aa364993%28v=vs.85%29.aspx)