Skip to content

Instantly share code, notes, and snippets.

@m4dEngi
Last active September 29, 2016 23:20
Show Gist options
  • Save m4dEngi/050fd9c92e4b0eb534cdecc0216e2486 to your computer and use it in GitHub Desktop.
Save m4dEngi/050fd9c92e4b0eb534cdecc0216e2486 to your computer and use it in GitHub Desktop.
#define STEAMWORKS_CLIENT_INTERFACES
#include "Steamworks.h"
CSteamAPILoader loader;
IClientEngine *pClientEngine;
IClientUser *pClientUser;
HSteamPipe hPipe = -1;
HSteamUser hUser;
void ReleaseSteam()
{
pClientEngine->ReleaseUser(hPipe, hUser);
pClientEngine->BReleaseSteamPipe(hPipe);
}
bool LoadSteam()
{
CreateInterfaceFn factory = loader.GetSteam3Factory();
if ( !factory )
{
fprintf(stderr, "Unable to load steamclient factory.\n");
return false;
}
pClientEngine = (IClientEngine *)factory( CLIENTENGINE_INTERFACE_VERSION, NULL );
if ( !pClientEngine )
{
fprintf(stderr, "Unable to get the client engine.\n");
return false;
}
hPipe = pClientEngine->CreateSteamPipe();
if( !hPipe || hPipe == -1 )
{
fprintf(stderr, "Unable to create pipe.\n");
return false;
}
hUser = pClientEngine->ConnectToGlobalUser(hPipe);
if ( !hUser )
{
fprintf(stderr, "Unable to create the global user.\n");
return false;
}
pClientUser = (IClientUser *)pClientEngine->GetIClientUser( hUser, hPipe, CLIENTUSER_INTERFACE_VERSION );
if ( !pClientUser )
{
fprintf(stderr, "Unable to get the client user interface.\n");
ReleaseSteam();
return false;
}
return true;
}
int main()
{
if(LoadSteam())
{
bool hasWallet;
CAmount amount;
CAmount amountPending;
bool success = pClientUser->BGetWalletBalance( &hasWallet, &amount, &amountPending );
if(success && hasWallet)
{
fprintf(stdout, "Amount m_nAmount: %d\n", amount.m_nAmount );
fprintf(stdout, "Amount m_eCurrencyCode: %d\n", amount.m_eCurrencyCode );
fprintf(stdout, "AmountPending m_nAmount: %d\n", amountPending.m_nAmount );
fprintf(stdout, "AmountPending m_eCurrencyCode: %d\n", amountPending.m_eCurrencyCode );
}
ReleaseSteam();
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment