So I am learning c++ and I was playing around with adding registry keys to make programs get added to startup. However I came across something which puzzled me slightly. When I used the normal way of adding something to startup in c++ it only got added when I ran it as admin. The thing that puzzled me is the fact that a lot of malware can add things to startup without requiring any admin priv's what so ever, using the same method of startup. Can someone please explain this? (I am assuming this thread is gonna be full of people whining about me being an idiot but I figure I may as well ask) Here is the code below:
PHP Code
<?php
#include<windows.h>
#include<string.h>
int main()
{
HKEY hkey;
DWORD dwDispoition;
RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\Run",0,KEY_ALL_ACCESS ,&hkey);
const unsigned char path[150] = "C:\\Windows\\system32\\notepad.exe";
RegSetValueEx(hkey,"Test Startup",0,1,path,sizeof(path));
return 0;
}


