I
I
ivanrotzer2021-03-25 18:59:46
C++ / C#
ivanrotzer, 2021-03-25 18:59:46

Why doesn't adding to startup using WinApi work?

I add a file to autoload, everything is added and shown in the task manager. But here's the problem: the status "Disabled" is shown in the dispatcher, which is why autorun does not occur. Here is the code:

HKEY hKey; 
    char szPath[] = "\"path\\to\\program\"";
    RegCreateKeyEx(HKEY_LOCAL_MACHINE, 
                 "Software\\Microsoft\\Windows\\CurrentVersion\\Run", 
                 NULL, 
                 "", 
                 REG_OPTION_NON_VOLATILE, 
                 KEY_SET_VALUE, 
                 NULL, 
                 &hKey,
                 NULL);

    if (hKey) 
    { 
        RegSetValueEx(hKey, "some program", NULL, REG_SZ, (LPBYTE)szPath, sizeof(szPath) + 1); 
        RegCloseKey(hKey); 
    }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question