Jump to content
  • Advertisement
Sign in to follow this  
aboeing

Win32 - C - Read Command Line Directory

This topic is 4351 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I seem to be having trouble in reading the directory in which I execute a command. (Win32 program). Example: C:\something> myprogram myargument if I then print out the string returned by GetCommandLine, I get: myprogram myargument if I print out the string from GetCurrentDirectory I get: C:\install_location_of_myprogram How can I get the directory from which I ran my program? (ie: C:\something) ? (I have tried reading the environment variable CD but that didnt work either) Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Not sure why your call to GetCommandLine is not returning the fully qualified path for you... it does this fine for me.

However, you can use GetModuleFileName which should do what you want...


GetModuleFileName(GetModuleHandle(NULL), filename_buffer, buffer_length);


Hope that helps!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!