程序自动启动
m_bAutoStart = !m_bAutoStart;
AfxGetApp()->WriteProfileInt(_T("User Info"), _T("AutoStart"), m_bAutoStart);
HKEY hKey;
LPCTSTR lpSubKey = _T("SOFTWARE//Microsoft//Windows//CurrentVersion//Run/0");
RegOpenKeyEx(HKEY_LOCAL_MACHINE, lpSubKey, 0L, KEY_ALL_ACCESS, &hKey);
if (m_bAutoStart)
{
TCHAR AppPathName[MAX_PATH];
GetModuleFileName(NULL, AppPathName, MAX_PATH);
LPCTSTR lpValue = AppPathName;
RegSetValueEx(hKey, _T("nsserver"), 0L, REG_SZ, (const BYTE *)lpValue, strlen(lpValue) +
1);
}
else
{
RegDeleteValue(hKey, _T("nsserver"));
}