C++获取本机登陆过的QQ号码示例程序
// FileName: GetQQ.h
#pragma once
#include <vector>
class GetQQ
{
private:
std::vector<CString> m_qqNum;
public:
GetQQ();
~GetQQ();
public:
// 获取QQ号码
std::vector<CString> Init(void);
};
// FileName: GetQQ.cpp
#include "stdafx.h" // 如果编译出错请删除这句
#include "GetQQ.h"
GetQQ::GetQQ()
{
}
GetQQ::~GetQQ()
{
}
std::vector<CString> GetQQ::Init(void)
{
TCHAR pathBuffer[MAX_PATH] = {0};
::SHGetSpecialFolderPath(NULL, pathBuffer, CSIDL_APPDATA, FALSE);
CString strPath(pathBuffer);
strPath += _T("\\Tencent\\Users\\*.*");
HANDLE hFile;
WIN32_FIND_DATA fileData;
hFile = FindFirstFile(strPath, &fileData);
FindNextFile(hFile, &fileData);
while (FindNextFile(hFile, &fileData))
{
// 如果是一个文件夹目录
if(fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
m_qqNum.push_back(fileData.cFileName);
fileData.cFileName;
}
}
return m_qqNum;
}