static bool SteamCheckActive(void) { bool result = false; HMODULE steamAPI = LoadLibrary("steam_api.dll"); if(steamAPI) { typedef bool (* _SteamAPI_IsSteamRunning)(void); _SteamAPI_IsSteamRunning SteamAPI_IsSteamRunning = NULL; // this just checks HKCU\Software\Valve\Steam\ActiveProcess\pid // to see if it's running, however process IDs can be reused and it doesn't clean the registry key // on exit SteamAPI_IsSteamRunning = (_SteamAPI_IsSteamRunning)GetProcAddress(steamAPI, "SteamAPI_IsSteamRunning"); if(SteamAPI_IsSteamRunning) { UInt32 startTime = GetTickCount(); const UInt32 kSteamTimeout = 10 * 1000; // 10 seconds while((GetTickCount() - startTime) >= kSteamTimeout) { if(SteamAPI_IsSteamRunning()) { result = true; break; } Sleep(100); } if(!result) { _ERROR("timed out waiting for steam boot"); } } else { _ERROR("couldn't get steam API ptr"); } FreeLibrary(steamAPI); } else { _ERROR("couldn't load steam API DLL (%08X)", GetLastError()); } return result; }
void SteamClient::joinLobby(QString lobbyIdStr) { if (!initialized) { if (SteamAPI_IsSteamRunning()) { init(); } else { qWarning() << "Steam is not running"; return; } } qDebug() << "Trying to join Steam lobby:" << lobbyIdStr; CSteamID lobbyId(lobbyIdStr.toULongLong()); SteamMatchmaking()->JoinLobby(lobbyId); }
int Steam::init() { //printf("Godot steam init\n"); isInitSuccess = SteamAPI_Init(); int err = FAILED; if (isInitSuccess) { err = OK; } if ( !SteamAPI_IsSteamRunning() ) { err = ERR_NO_CLIENT; } else if ( !SteamUser()->BLoggedOn() ) { err = ERR_NO_CONNECTION; } return err; }
void SteamClient::requestTicket(TicketRequestCallback callback) { if (!initialized) { if (SteamAPI_IsSteamRunning()) { init(); } else { qWarning() << "Steam is not running"; callback(INVALID_TICKET); return; } } if (!initialized) { qDebug() << "Steam not initialized"; return; } steamCallbackManager.getTicketRequests().startRequest(callback); }
void CTimer::Stop(bool endTrigger /* = false */) { if (endTrigger && !m_bWereCheatsActivated) { // Post time to leaderboards if they're online // and if cheats haven't been turned on this session if (SteamAPI_IsSteamRunning()) PostTime(); //Save times locally too, regardless of SteamAPI condition Time t; t.ticks = gpGlobals->tickcount - m_iStartTick; t.tickrate = gpGlobals->interval_per_tick; time(&t.date); localTimes.AddToTail(t); SaveTime(); } SetRunning(false); DispatchStateMessage(); }
SB_API bool S_CALLTYPE IsSteamRunning() { return SteamAPI_IsSteamRunning(); }
SW_PY bool IsSteamRunning(void) { return SteamAPI_IsSteamRunning(); }
bool SteamClient::init() { if (SteamAPI_IsSteamRunning() && !initialized) { initialized = SteamAPI_Init(); } return initialized; }
// checks if a local Steam client is running bool System_IsSteamRunning(){return SteamAPI_IsSteamRunning();/*глючит проверь*/};
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { // // Console window is required for the program to automatically close when the user quits Steam // if(AllocConsole()) { FILE* stream = nullptr; freopen_s(&stream, "CONOUT$", "w", stdout); freopen_s(&stream, "CONOUT$", "w", stderr); freopen_s(&stream, "CONIN$", "r", stdin); printf("SteamMusicKeys\n\n"); } printf("Searching for Steam... "); bool SteamAPI_SteamIsRunning = SteamAPI_IsSteamRunning(); for(int i = 0; i < STEAMAPI_STEAMISRUNNING_RETRY_COUNT; i++) { if(SteamAPI_SteamIsRunning = SteamAPI_IsSteamRunning()) { printf("Found!\n"); break; } Sleep(STEAMAPI_STEAMISRUNNING_RETRY_DELAY); } if(!SteamAPI_SteamIsRunning) { printf("Not Found!\n"); MessageBox(0,L"ERROR: Could not initialize SteamAPI (Steam is not running)", 0, 0); FreeConsole(); return 1; } printf("Initializing SteamAPI...\n"); if(!SteamAPI_Init()) { MessageBox(0, L"ERROR: Could not initialize SteamAPI", 0, 0); FreeConsole(); return 2; } printf("Initializing Steam Music...\n"); if(!(IMus = SteamMusic())) { MessageBox(0, L"ERROR: Could not initialize Steam Music", 0, 0); SteamAPI_Shutdown(); FreeConsole(); return 3; } printf("Creating dummy window...\n"); HWND hWnd = SMK_CreateDummyWindow(hInstance, L"SteamMusicKeys"); if(!hWnd) { MessageBox(0, L"ERROR: Could not create dummy window", 0, 0); SteamAPI_Shutdown(); FreeConsole(); return 4; } printf("Registering hotkeys...\n"); SMK_RegisterHotkeys(hWnd); printf("Hiding console...\n"); ShowWindow (GetConsoleWindow(), SW_HIDE); SMK_MessageLoop(); printf("Showing console...\n"); ShowWindow (GetConsoleWindow(), SW_SHOW); printf("Freeing Hotkeys...\n"); SMK_UnregisterHotkeys(hWnd); printf("Freeing SteamAPI\n"); SteamAPI_Shutdown(); printf("Freeing Console\n"); FreeConsole(); return 0; }