| 26 | static char sKey[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Run"; |
| 27 | |
| 28 | BOOL CRegRun::AutoRun(BOOL bAutoRun, const char *procname) |
| 29 | { |
| 30 | CRegKey regRun; |
| 31 | int ret; |
| 32 | |
| 33 | if (bAutoRun) { |
| 34 | if (!IfAutoRun()) { |
| 35 | ret = regRun.Create(HKEY_LOCAL_MACHINE, sKey); |
| 36 | if (ret == ERROR_SUCCESS) { |
| 37 | regRun.SetStringValue(m_sRegName.GetString(), procname, REG_SZ); |
| 38 | regRun.Close(); |
| 39 | } else { |
| 40 | m_sErrMsg.Format("CRegKey::Create sKey(%s) error(%d)", sKey, ret); |
| 41 | m_nErrno = ret; |
| 42 | return FALSE; |
| 43 | } |
| 44 | } |
| 45 | } else { |
| 46 | ret = regRun.Open(HKEY_LOCAL_MACHINE, sKey, KEY_ALL_ACCESS); |
| 47 | if (ret == ERROR_SUCCESS) { |
| 48 | regRun.DeleteValue(m_sRegName.GetString()); |
| 49 | regRun.Close(); |
| 50 | } else { |
| 51 | m_sErrMsg.Format("CRegKey::Open sKey(%s) error(%d)", sKey, ret); |
| 52 | m_nErrno = ret; |
| 53 | return FALSE; |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | return TRUE; |
| 58 | } |
| 59 | |
| 60 | BOOL CRegRun::IfAutoRun() |
| 61 | { |
no test coverage detected