0

I want to get the desktop dir folder, so I tried:

  char filename[ MAX_PATH ];
  char newLocation[]="%userprofile%\\desktop\\myfile.exe";
  BOOL stats=0;
  DWORD size = GetModuleFileNameA( NULL, filename, MAX_PATH );
  CopyFile(filename, newLocation, stats);

%userprofile% is not working. how can I get the user profile path?

RGS
  • 4,062
  • 4
  • 31
  • 67
  • 1
    I think this link can halp you.. http://stackoverflow.com/questions/17933917/get-the-users-desktop-folder-using-windows-api – Thomas May 27 '16 at 09:30

1 Answers1

0

Maybe this other answers will help:

https://superuser.com/questions/571974/userprofile-variable-not-working

or:

https://superuser.com/questions/442158/why-cant-i-use-userprofile-in-path

You can type:

set

In a command prompt you will get a list of all environment variables defined on your system.

Community
  • 1
  • 1
Destrif
  • 2,104
  • 1
  • 14
  • 22
  • thank you for your answer! yeah, I think in C I cannot use %userprofile% or %windir%... i will check this links! – RGS May 27 '16 at 09:39
  • So maybe this will be more helpfull?(C++) http://stackoverflow.com/questions/6827496/how-to-properly-use-userprofile-inside-code – Destrif May 27 '16 at 10:07