C++获取本机登陆过的QQ号码示例程序
本文导语: 先看效果图,代码在下面 代码如下:// FileName: GetQQ.h #pragma once #include class GetQQ{private: std::vector m_qqNum; public: GetQQ(); ~GetQQ();public: // 获取QQ号码 std::vector Init(void);}; 代码如下:// FileName: GetQQ.cpp #include "stdaf...
// FileName: GetQQ.h
#pragma once
#include
class GetQQ
{
private:
std::vector m_qqNum;
public:
GetQQ();
~GetQQ();
public:
// 获取QQ号码
std::vector Init(void);
};
// FileName: GetQQ.cpp
#include "stdafx.h" // 如果编译出错请删除这句
#include "GetQQ.h"
GetQQ::GetQQ()
{
}
GetQQ::~GetQQ()
{
}
std::vector 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;
}