View difference between Paste ID: a3Bmf67H and U85ZSrnY
SHOW: | | - or go back to the newest paste.
1
TCHAR szPath[MAX_PATH];
2
GetModuleFileName(NULL,szPath,MAX_PATH);
3
HKEY newValue;
4
HKEY resKey;
5
subValue = "MyProgram";
6
    long key = RegQueryValueExA(resKey, subValue, NULL, NULL, NULL, NULL);
7
    if(key == ERROR_FILE_NOT_FOUND)
8
    {
9
        return false;
10
    }
11
    else
12
    {
13
      const DWORD cbData = sizeof(TCHAR) * (lstrlen(szPath) + 1);
14-
      RegSetValueEx(newValue, subValue ,0,REG_SZ,(LPBYTE)szPath,sizeof(szPath));
14+
15
      RegSetValueEx(newValue, subValue ,0,REG_SZ,(LPBYTE)szPath,cbData);
16
      RegCloseKey(newValue);
17
    }