⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qq自动登陆器.cpp

📁 QQ自动登陆器
💻 CPP
字号:
// QQ自动登陆器.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "QQ自动登陆器.h"
#include "QQ自动登陆器Dlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CQQAutoLogon

BEGIN_MESSAGE_MAP(CQQAutoLogon, CWinApp)
	//{{AFX_MSG_MAP(CQQAutoLogon)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG
	ON_COMMAND(ID_HELP, OnHelp)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CQQAutoLogon construction

CQQAutoLogon::CQQAutoLogon()
{
	// TODO: add construction code here,
	// Place all significant initialization in InitInstance
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CQQAutoLogon object

CQQAutoLogon theApp;

/////////////////////////////////////////////////////////////////////////////
// CQQAutoLogon initialization

BOOL CQQAutoLogon::InitInstance()
{
	AfxEnableControlContainer();

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif

//----------------------------------

	CString szCMD = CString(GetCommandLine());
	//szCMD = "\"qqlogon.exe /nownd /logon /exit /config:\"D:\\登陆器\\conf.ini\"\" ";
	//szCMD = "qqlogon.exe /nownd /logon /exit /config:\"D:\\登陆器\\conf.ini\" ";
	RemoveQuota(szCMD);
	BOOL ParseCMDOK = FALSE;
	if (!IsCMDEmpty(szCMD))
	{
		ParseCMDOK = ParseCMD(szCMD, g_RunWithOS, g_AutoLogon, g_AutoExit, g_ConfigFilePath);
	}

	// 检查配置文件
	BOOL CmdConfigValid = FALSE;
	if (!g_ConfigFilePath.IsEmpty())
	{
		if (-1 == g_ConfigFilePath.Find(":"))
		{
			if (-1 == g_ConfigFilePath.Find("\\"))
			{
				g_ConfigFilePath = GetConfFile(g_ConfigFilePath);
			}
		}
		CmdConfigValid = IsFileExist(g_ConfigFilePath);
	}
	if (!CmdConfigValid)
	{
		CString FullName;
		CString FileName;
		CString NameNoExt;
		GetCurrentFile(FullName, FileName, NameNoExt);
		CString ConfigFileName = NameNoExt+="配置.ini";
		g_ConfigFilePath = GetConfFile(ConfigFileName);
	}

	if (!IsFileExist(g_ConfigFilePath))
	{
		if (!WriteIniHelpInfo(HELP_INFO, HELPLINE, g_ConfigFilePath))
		{
			ConfigFileError();
			return FALSE;
		}
		QQPathValid = FindQQ(g_QQPath);
		WritePrivateProfileString(MAIN_CONFIG,QQ_PATH,g_QQPath,g_ConfigFilePath);
		WritePrivateProfileString(MAIN_CONFIG,RUN_WITH_OS,g_RunWithOS,g_ConfigFilePath);
		WritePrivateProfileString(MAIN_CONFIG,AUTO_LOGON,g_AutoLogon,g_ConfigFilePath);
		WritePrivateProfileString(MAIN_CONFIG,AUTO_EXIT,g_AutoExit,g_ConfigFilePath);
		WritePrivateProfileString(MAIN_CONFIG,WND_TOPMOST,g_WndTopMost,g_ConfigFilePath);
		WritePrivateProfileString(MAIN_CONFIG,QQLIST_LEN,"0",g_ConfigFilePath);
	}
	else
	{
		if (ParseCMDOK)
		{
			if (g_RunWithOS == "是")
			{
				WritePrivateProfileString(MAIN_CONFIG,RUN_WITH_OS,g_RunWithOS,g_ConfigFilePath);
			}
			if (g_AutoLogon == "是")
			{
				WritePrivateProfileString(MAIN_CONFIG,AUTO_LOGON,g_AutoLogon,g_ConfigFilePath);
			}
			if (g_AutoExit == "是")
			{
				WritePrivateProfileString(MAIN_CONFIG,AUTO_EXIT,g_AutoExit,g_ConfigFilePath);
			}
		}
		if (!GetIniFileStr(MAIN_CONFIG, QQ_PATH, g_QQPath, g_ConfigFilePath))
		{
			ConfigFileError();
			return FALSE;
		}
		else
		{
			QQPathValid = IsFileExist(g_QQPath);
			if (!QQPathValid)
			{
				QQPathValid = FindQQ(g_QQPath);
				WritePrivateProfileString(MAIN_CONFIG,QQ_PATH,g_QQPath,g_ConfigFilePath);
			}
		}
		if (!GetIniFileStr(MAIN_CONFIG, RUN_WITH_OS, g_RunWithOS, g_ConfigFilePath))
		{
			ConfigFileError();
			return FALSE;
		}
		else
		{
			if (g_RunWithOS == "是")
			{
				SetQQAutoRun(g_ConfigFilePath);
			}
			else
			{
				SetQQAutoRun(g_ConfigFilePath, TRUE);
			}
		}
		if (!GetIniFileStr(MAIN_CONFIG, AUTO_LOGON, g_AutoLogon, g_ConfigFilePath))
		{
			ConfigFileError();
			return FALSE;
		}
		if (!GetIniFileStr(MAIN_CONFIG, AUTO_EXIT, g_AutoExit, g_ConfigFilePath))
		{
			ConfigFileError();
			return FALSE;
		}
		if (!GetIniFileStr(MAIN_CONFIG, WND_TOPMOST, g_WndTopMost, g_ConfigFilePath))
		{
			ConfigFileError();
			return FALSE;
		}
		
		g_QQListLength = GetPrivateProfileInt(MAIN_CONFIG,QQLIST_LEN,0,g_ConfigFilePath);
		if (g_QQListLength > 0)
		{
			if (!ReadIniQQList(QQLIST_CONTENT, QQLISTNO, QQInfoList, g_ConfigFilePath, g_QQListLength))
			{
				// 列表不为空但读取失败,则清空列表并重新写入长度
				g_QQListLength = CheckIniQQListLen(QQLIST_CONTENT, QQLISTNO, g_ConfigFilePath, g_QQListLength);
				CString QQCount;
				QQCount.Format("%d",g_QQListLength);
				WritePrivateProfileString(MAIN_CONFIG,QQLIST_LEN,QQCount,g_ConfigFilePath);
				if (0 == g_QQListLength) // 第一个QQ号都读取失败就清空列表
				{
					WritePrivateProfileString(QQLIST_CONTENT,NULL,NULL,g_ConfigFilePath);
				}

				// 不退出,再尝试读一次,再不行就退出
				if (!ReadIniQQList(QQLIST_CONTENT, QQLISTNO, QQInfoList, g_ConfigFilePath, g_QQListLength))
				{
					ConfigFileError();
					return FALSE;
				}
			}
		}
		// 列表为空时,不自动登陆,不自动退出
		if (g_QQListLength<=0)
		{
			g_AutoLogon == "否";
			WritePrivateProfileString(MAIN_CONFIG,AUTO_LOGON,g_AutoLogon,g_ConfigFilePath);
			g_AutoExit == "否";
			WritePrivateProfileString(MAIN_CONFIG,AUTO_EXIT,g_AutoExit,g_ConfigFilePath);
		}

		// 列表不为空并且要求程序启动就直接登陆
		if (QQPathValid&&g_QQListLength>0&&g_AutoLogon=="是")
		{
			vector<CString> LogonedQQList;
			FindLogonedQQ(LogonedQQList);
			for (int i = 0; i < QQInfoList.size(); i++)
			{
				if (QQInfoList[i].IsUsing() && !IsInLogonedList(QQInfoList[i].GetQQNbr(), LogonedQQList))
				{
					RunQQ(g_QQPath,QQInfoList[i].GetQQLogonStr());
				}
			}
			if (g_AutoExit == "是")
			{
				return FALSE;
			}
		}
	}


//------------------------------------


	CQQDlg dlg;
	m_pMainWnd = &dlg;
	int nResponse = dlg.DoModal();
	if (nResponse == IDOK)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with OK
	}
	else if (nResponse == IDCANCEL)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with Cancel
	}

	// Since the dialog has been closed, return FALSE so that we exit the
	//  application, rather than start the application's message pump.
	return FALSE;
}

void CQQAutoLogon::OnHelp()
{
	CTabCtrl* pQListTab = (CTabCtrl*)((CDialog*)AfxGetMainWnd())->GetDlgItem(IDC_TAB1);
	pQListTab->SetCurSel(2);
	NMHDR   nmhdr;
	nmhdr.code=TCN_SELCHANGE;   
	nmhdr.hwndFrom=pQListTab->GetSafeHwnd(); 
	nmhdr.idFrom=IDC_TAB1;
	::SendMessage(nmhdr.hwndFrom,WM_NOTIFY,(WPARAM)IDC_TAB1,(LPARAM)(&nmhdr));
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -