I am very confused about the WindowsAPI function
GetCurrentDirectory
When my application get’s started from the autostart (HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run) the current directory is ALWAYS : %windir%\system32
Why is that?
That’s as expected. By default, applications inherit the current directory from the parent process, and most system components use system32 as the current directory.
When you launch an application by double-clicking, Explorer goes to the trouble of explicitly setting the current directory. When an application is launched from the Run key, it doesn’t. There’s probably no particular reason why not, just that the programmers who wrote the code for processing the Run key either didn’t think about it or didn’t think it was worth the effort.