Auto run on windows startup problem

I want my application automatically launch at windows startup, according to what i founds on internet a key must be added to windows registry. By using code below i added the key. When i open stated directory on registry, key is there. But application doesn't start on startup. What is wrong?

Some people add the key to HKEY_LOCAL_MACHINE instead of HKEY_CURRENT_USER so I changed the that part of code as HKEY_LOCAL_MACHINE but this time key is not added. Rest of the code is same but it didn't work.

Yes, I dynamically compiled it and added necessary .dlls to exe folder. It works fine. Only auto start feature remain. I can think installer solution if I can't find a way to handle it by using registry. I want to add an option in program which determine whether auto start on or off. As far as I know you can not accomplish this in your solution.

By the way I learned that if your windows is 64-bit, operations on HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run directory, automatically redirected to HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run directory. I found the key on second directory. But still it doesn't work.

I open windows task manager as soon as windows start and my app is in the processes list but it disappears in several seconds. I tried same thing with an empty gui project it works. I think finding this problem will be a big trouble so I give up.