Kat64

Hi,

I am writing a small software installation program which copies files from my disk to the C Drive: of the destination computer. My laptop has designated my CD drive to be Drive D: , but my home computer as well as some of my client's computers designate drive E: to be the CD drive.

First: How can my program which is running off of a CD drive, pick up this drive location

Second: Can this information be stored in a variable so instead of my program hard coding the drive such as:
CopyFile("D:\\InstallationFiles\\Sample_Documents\\My_Doc.doc","C:\\Test\\Sample_Documents\\MyDoc.doc", false);

it would use a variable like Drive_Location and be used in the following command as such:
CopyFile("Drive_Location:\\InstallationFiles\\Sample_Documents\\My_Doc.doc","C:\\Test\\Sample_Documents\\My_Doc.doc", false);

I would appreciate your help.
Thanks so much,
Kat



Re: Visual C++ Language How do I retrieve the Drive location for my program to use?

kirants

_splitpath



Re: Visual C++ Language How do I retrieve the Drive location for my program to use?

Grenouille12345

Hi!

Using _getcwd, you should be able to retrieve the current working directory (usually your executable) and then retrieve the drive with _splitpath...

Good luck!

Grenouille12345





Re: Visual C++ Language How do I retrieve the Drive location for my program to use?

Nishant Sivakumar

The easiest and safest way to get the drive from which your app is running is to use GetModuleFileName.

Note that getting the current working directory may not return the drive the app's running from as the working directory can be separately set to some other directory (potentially on a different drive).





Re: Visual C++ Language How do I retrieve the Drive location for my program to use?

Kat64

Okay,

I'll give it a shot and I'll let you know if it worked!

Thanks

Kat