ciyo
ciyo

Reputation: 735

Changing Directory to Desktop

I need to change my program directory to desktop regardless user name in C++ on Windows 7 and XP. I am currently using _chdir() function. I tried _chdir("Desktop") and _chdir("desktop") but it returned -1.

Is there way to do that? Thank you!

Upvotes: 0

Views: 826

Answers (1)

Skeen
Skeen

Reputation: 4732

Read the %HOMEPATH% environment variable, change to that directory and then to the desktop directory.

Upvotes: 1

Related Questions