Mr. Pig’s House of Bacon

August 29, 2007

XFire Related Random Code

Filed under: Uncategorized — Mr. Pig @ 2:05 pm

Well, I haven’t posted in a while so I decided to post the next bit of code I worked on… and it turns out it was getting a list of users (usernames) someone with xfire installed has.

I decided it’d be easiest to just check inside the chatlogs directory. (which is under documents and settings)

Here’s how to do it in C++:

// Let’s grab our username so we can scan first
char userName[256] = “”;
DWORD sizeOf = sizeof(userName);
GetUserNameA(userName, &sizeOf);
string sysUsername = userName; //Save it

string userList = “XFire->getUsers\n===============\n\n”;

WIN32_FIND_DATAA findData;
memset(&findData, 0, sizeof(findData));
HANDLE findHandle = NULL;
string file = “”;

// Let’s get the first file
findHandle = FindFirstFileA(string(“C:\\Documents and Settings\\” + sysUsername + “\\Application Data\\Xfire\\chatlog\\*”).c_str(), &findData); //Get the first file

// Let’s get the rest of the files
do {
file = findData.cFileName;

if (findData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY && (file != “.” && file != “..”))
userList += file + “\n”;
} while (FindNextFileA(findHandle, &findData) != 0); //Get the next file in order (loop until finished)

FindClose(findHandle);

userList += “*** End List ***\n”;

return userList;

Leave a Reply