Tag Archives: Steam

Getting the SteamID of current user using Steam_API

This is the code I used when integrating ManaGuardian with Steam.
I could not find any other posts regarding this so I am publishing my code for reference. I hope it helps

Steam API header files from valve SDK are required

https://github.com/ValveSoftware/source-sdk-2013/tree/master/sp/src/public/steam

//Initialize Steam API

InitResult irResult = g_oSteamAPI.Initialize(g_szAppPath);

if (irResult != IR_SUCCESS)
    return EXIT_FAILURE;

//Open Steam User Interface
ISteamUser* pSteamUser = g_oSteamAPI.GetSteamUserInterface();

if (!pSteamUser)
    return EXIT_FAILURE;

CSteamID sSteamID = pSteamUser->GetSteamID();
uint64 uSteamID = sSteamID.ConvertToUint64();
char cSteamID[64];
sprintf(cSteamID, "%lld", (long long)uSteamID);
printf("User SteamID : %s\n", cSteamID);

The code is pretty much self-explanatory.