lol... you're right, here is the code :p. I think you found out pretty much everythign anyway. As for "HandleMessengerStart" it's just here as a user setting (how did you know about it? I don't remember giving this information publicly :). I added it in case someone wouldn't want Plus! to create it's own /Winstart key for some obscure technical reason.
code:
//
///////////////////////////////////////////////////////////////
void CMsgPlusUtilWnd::PreventAutoMessengerStart()
{
try
{
TRACE("CMsgPlusUtilWnd::PreventAutoMessengerStart - called");
//Removes Messenger from Windows starts and remember the command lines
CRegKey reg;
if(reg.Open(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Run")) == ERROR_SUCCESS)
{
TCHAR sPath[1024]; sPath[0] = '\0';
ULONG nSize = 1024;
reg.QueryStringValue(CPreferences::GetMessengerVersion() < 5 ? _T("MSMSGS") : _T("msnmsgr"), sPath, &nSize);
reg.DeleteValue(_T("MessengerPlus2")); //Delete the old value
CRegKey regMP;
regMP.Create(HKEY_CURRENT_USER, _T("Software\\Patchou\\MsgPlus2"));
DWORD nEnable = 1;
regMP.QueryDWORDValue(_T("HandleMessengerStart"), nEnable);
if(nEnable)
{
//First, check if we can do something here
regMP.QueryDWORDValue(_T("HandleMessengerStart"), nEnable);
if(sPath[0] == '\0')
{
TCHAR sMPPath[1024]; sMPPath[0] = '\0';
DWORD nSize = 1024;
regMP.QueryStringValue(CPreferences::GetMessengerVersion() < 5 ? _T("AutoMsg4Start") : _T("AutoMsg5Start"), sMPPath, &nSize);
if(sMPPath[0] == '\0')
return;
}
//Check if Messenger is set to start automatically
bool bMessengerStart = false;
CRegKey regAdmin;
DWORD nNotAdminMode = FALSE;
if(regAdmin.Open(HKEY_CURRENT_USER, _T("Software\\Patchou\\MsgPlus2"), KEY_READ) == ERROR_SUCCESS)
{
regAdmin.QueryDWORDValue(_T("NotAdminMode"), nNotAdminMode);
regAdmin.Close();
}
if(!nNotAdminMode)
{
if(CPreferences::GetMessengerVersion() < 5)
{
CRegKey reg;
if(reg.Open(HKEY_CURRENT_USER, _T("Software\\Microsoft\\MessengerService")) == ERROR_SUCCESS)
{
DWORD nAppSettings = 0;
reg.QueryDWORDValue(_T("AppSettings"), nAppSettings);
if(nAppSettings & 0x200)
bMessengerStart = true;
}
}
else
{
CRegKey reg;
if(reg.Open(HKEY_CURRENT_USER, _T("Software\\Microsoft\\MSNMessenger")) == ERROR_SUCCESS)
{
DWORD nAppSettings = 0;
reg.QueryDWORDValue(_T("AppSettings"), nAppSettings);
if(nAppSettings & 0x200)
bMessengerStart = true;
}
}
}
//Add or remove our MP start value?
if(bMessengerStart)
{
//Add a special Messenger Plus! command line
string sMPCmdLine = _T("\"");
sMPCmdLine += CPreferences::GetMessengerPlusBinDir();
sMPCmdLine += _T("\\");
sMPCmdLine += CPreferences::GetMsgPlusExeName();
sMPCmdLine += _T("\" /WinStart");
reg.SetStringValue(_T("MessengerPlus3"), sMPCmdLine);
//Remember the path
if(sPath[0] != '\0')
regMP.SetStringValue(CPreferences::GetMessengerVersion() < 5 ? _T("AutoMsg4Start") : _T("AutoMsg5Start"), sPath);
reg.DeleteValue(CPreferences::GetMessengerVersion() < 5 ? _T("MSMSGS") : _T("msnmsgr"));
}
else
regMP.DeleteValue(CPreferences::GetMessengerVersion() < 5 ? _T("AutoMsg4Start") : _T("AutoMsg5Start"));
}
else
reg.DeleteValue(_T("MessengerPlus3"));
}
TRACE("CMsgPlusUtilWnd::PreventAutoMessengerStart - exited");
}
catch(...)
{
TRACE("An exception was thrown in CMsgPlusUtilWnd::PreventAutoMessengerStart");
}
}