Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I get the drive letter of CD?that the program run from it

Status
Not open for further replies.

powerbuilde

Programmer
Oct 2, 2010
29
EG
I want to make my app run from CD
I put Exe file and database on Cd
I edit the registry using RegistrySet
I connect to database at CD using profile made in registry
but how I know what is the correct letter for CD drive
may be it is d: or e: or f:
or may be the computer have more than on CD Drive
thanks
 
If you are running the exe from a CD then the drive letter of the executable path is the drive letter you want.

Declare an external function:
Code:
FUNCTION int GetModuleFileNameA(&
           ulong hinstModule, &
           REF string lpszPath, &
           ulong cchPath) LIBRARY "kernel32"

Then you can get the path:
Code:
string ls_Path
unsignedlong lul_handle

ls_Path = space(1024)

lul_handle = Handle(GetApplication())
GetModuleFilenameA(lul_handle, ls_Path, 1024)

Then you parse 'ls_Path' to get the drive letter.

Matt

"Nature forges everything on the anvil of time"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top