00001
00002
00003
00004
00005
00006 #include "stdafx.h"
00007 #include "fsAutorunMgr.h"
00008
00009 #ifdef _DEBUG
00010 #undef THIS_FILE
00011 static char THIS_FILE[]=__FILE__;
00012 #define new DEBUG_NEW
00013 #endif
00014
00015 fsAutorunMgr::fsAutorunMgr()
00016 {
00017 m_hAutoStart = NULL;
00018 }
00019
00020 fsAutorunMgr::~fsAutorunMgr()
00021 {
00022
00023 }
00024
00025 BOOL fsAutorunMgr::SetAutoStart(BOOL bSet)
00026 {
00027 if (FALSE == OpenAutoStartKey ())
00028 return FALSE;
00029
00030 TCHAR szModule [1000 + 50];
00031 *szModule = 0;
00032 BOOL bRet;
00033
00034
00035 GetModuleFileName (NULL, szModule, 1000);
00036
00037 if (bSet)
00038 {
00039
00040 _tcscat (szModule, _T (" -autorun"));
00041 bRet = ERROR_SUCCESS == RegSetValueEx (m_hAutoStart, _T ("Open Download Manager - RCS"), 0, REG_SZ, (CONST BYTE*) szModule, _tcslen (szModule) + 1);
00042 }
00043 else
00044 {
00045 bRet = ERROR_SUCCESS == RegDeleteValue (m_hAutoStart, _T ("Open Download Manager - RCS"));
00046 }
00047
00048 CloseAutoStartKey ();
00049
00050 return bRet;
00051 }
00052
00053 BOOL fsAutorunMgr::OpenAutoStartKey()
00054 {
00055
00056 if (ERROR_SUCCESS != RegOpenKey (HKEY_CURRENT_USER,
00057 _T ("Software\\Microsoft\\Windows\\CurrentVersion\\Run"), &m_hAutoStart))
00058 return FALSE;
00059
00060 return TRUE;
00061 }
00062
00063 void fsAutorunMgr::CloseAutoStartKey()
00064 {
00065 RegCloseKey (m_hAutoStart);
00066 }
00067
00068 BOOL fsAutorunMgr::IsAutoStart()
00069 {
00070 if (FALSE == OpenAutoStartKey ())
00071 return FALSE;
00072
00073 DWORD dwType;
00074
00075 return ERROR_SUCCESS == RegQueryValueEx (m_hAutoStart, _T ("Open Download Manager - RCS"), NULL,
00076 &dwType, NULL, NULL);
00077 }