Here's a code snippet form CodeProject.org about adding a program to the system registry for it to start up.
the bolded text is text i had to replace to get it to compile (from strlen() to _tcslen)) I'm in UNICODE mode... if that makes any differenceCode:bool CWinStartup::AddApp(LPCTSTR lpszName, LPCTSTR lpszPath, StartupUser user) { HKEY hRootKey; if (user == CurrentUser) { hRootKey = HKEY_CURRENT_USER; } else { hRootKey = HKEY_LOCAL_MACHINE; } HKEY hKey = 0; HRESULT hr = RegOpenKey(hRootKey, KEY_STARTUP, &hKey); if (hr == ERROR_SUCCESS) { hr = RegSetValueEx(hKey, lpszName, 0, REG_SZ, (const BYTE*)lpszPath, _tcslen(lpszPath)); RegCloseKey(hKey); } return (hr == ERROR_SUCCESS); }
When I call that from a MFC program, it only puts a part of the lpszPath in the registry (first 11 chars of any string I give it)
Heres me calling it:
In the registry, it only shows up as D:\DEARD\EA for the path, the name is correct. I've tried using wchar_t, char, and LPCTSTR for the path, they all offer the same results. i've also put the string in _T("") in the actual function, nothing different...Code:LPCTSTR PATH = _T("D:\\DEARD\\EATEAR\\KDEKAR"); TCHAR NAME[] = _TEXT("AntiLeet"); CWinStartup startup; startup.AddApp(NAME, PATH, CurrentUser);
Why?
Thanks,
Matt



LinkBack URL
About LinkBacks




