Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h> //WinAPI functions and structures
- #include <iostream> // For standard c++ library (cout, etc)
- #include <string> // For standard c++ string manipulation
- #include <sstream> // For standard c++ string stream (string manipulation)
- #include <fstream> // For standard c++ file I/O (writing, reading, etc)
- #include <WinInet.h> // For internet usage, for DeleteUrlCacheEntryW function.
- #include <urlmon.h> // For downloading a file from url.
- #pragma comment(lib, "wininet.lib") // For linking against wininet.dll so we can use it's functions
- #pragma comment(lib, "urlmon.lib") // For linking against urlmon.dll so we can download files from url
- using std::cout; // This is better way than doing: using namespace std;
- using std::cin;
- using std::endl;
- int main()
- {
- std::string SteamProfileLink;
- std::string FileName = "steamprofile.dat";
- std::string SteamBuffer, LobbyId;
- std::ifstream FileReader;
- cout << "Please Enter a Link to Target Steam Profile:";
- cin >> SteamProfileLink; // save link to a string
- cout << "Attempting to join a lobby..." << endl;
- DeleteUrlCacheEntryA(SteamProfileLink.c_str()); // Delete cache, so we wont download old data
- HRESULT DownloadResult = URLDownloadToFileA(0, SteamProfileLink.c_str(), FileName.c_str(), 0, 0); // Download steam profile to file
- if (SUCCEEDED(DownloadResult)) //Check if download was succesful
- {
- FileReader.open(FileName);
- if (FileReader.is_open())
- {
- std::ostringstream FileBuffer; // Create stringstream
- FileBuffer << FileReader.rdbuf(); // read file to that string stream
- SteamBuffer = FileBuffer.str(); // store buffer to string
- if (SteamBuffer.find("steam://joinlobby/730/") != std::string::npos) // Check if user is in lobby
- {
- std::size_t LobbyIdStart, LobbyIdEnd;
- LobbyIdStart = SteamBuffer.find("steam://joinlobby/730/");
- if (LobbyIdStart != std::string::npos)
- {
- LobbyIdEnd = SteamBuffer.find("\"", LobbyIdStart);
- if (LobbyIdEnd != std::string::npos) {
- LobbyId = SteamBuffer.substr(LobbyIdStart, LobbyIdEnd - LobbyIdStart);
- cout << "Lobby ID is: " << LobbyId << endl;
- cout << "Joining lobby..." << endl;
- ShellExecuteA(0, "open", LobbyId.c_str(), 0, 0, SW_SHOWNORMAL); // Join to the lobby
- }
- }
- }
- else {
- cout << "Error: User not in lobby!" << endl;
- }
- }
- else {
- cout << "Error: Failed to open downloaded file!" << endl;
- }
- }
- else {
- cout << "Error: Failed to download profile information!" << endl;
- }
- FileReader.close();
- std::remove(FileName.c_str());
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement