/*
@設置開機自啟動
@strUser,用戶名
@strPass,密碼
@strAutoAdminLogon,當該值為1時自動登錄,0取消
@return,成功返回TRUE,否則返回FALSE
*/
BOOL SetWindowAutoLogin(LPCTSTR strUser,LPCTSTR strPass,LPCTSTR strAutoAdminLogon)
{
HKEY hKey;
LONG ntStatus = RegOpenKey(HKEY_LOCAL_MACHINE,_T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon"),&hKey);
if (ERROR_SUCCESS != ntStatus)
return FALSE;
ntStatus = RegSetValueEx(hKey,_T("DefaultUserName"),0,REG_SZ,(CONST BYTE*)strUser,_tcslen(strUser)*sizeof(TCHAR));
if (ERROR_SUCCESS != ntStatus)
return FALSE;
ntStatus = RegSetValueEx(hKey,_T("DefaultPassword"),0,REG_SZ,(CONST BYTE*)strPass,_tcslen(strPass)*sizeof(TCHAR));
if (ERROR_SUCCESS != ntStatus)
return FALSE;
ntStatus = RegSetValueEx(hKey,_T("AutoAdminLogon"),0,REG_SZ,(CONST BYTE*)strAutoAdminLogon,_tcslen(strAutoAdminLogon)*sizeof(TCHAR));
if (ERROR_SUCCESS != ntStatus)
return FALSE;
RegCloseKey(hKey);
return TRUE;
}