Skip to content

Commit

Permalink
Added SKIF_Util_GetProcessHandleFromHwnd()
Browse files Browse the repository at this point in the history
  • Loading branch information
Aemony committed Apr 21, 2024
1 parent a8189f0 commit d6370c6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions include/utility/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ bool SKIF_Util_IsTouchCapable (void);
bool SKIF_Util_IsProcessAdmin (DWORD PID);
bool SKIF_Util_IsProcessX86 (HANDLE process);
PROCESSENTRY32W SKIF_Util_FindProcessByName (const wchar_t* wszName);
HANDLE SKIF_Util_GetProcessHandleFromHwnd (HWND hwnd, DWORD dwDesiredAccess);
bool SKIF_Util_SaveExtractExeIcon (std::wstring exePath, std::wstring targetPath);
bool SKIF_Util_GetDragFromMaximized (bool refresh = false);
bool SKIF_Util_GetControlledFolderAccess (void);
Expand Down
6 changes: 0 additions & 6 deletions src/SKIF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2244,12 +2244,6 @@ wWinMain ( _In_ HINSTANCE hInstance,
if (RepositionSKIF)
RepositionSKIF = false;

static ImGuiTabBarFlags flagsInjection =
ImGuiTabItemFlags_None,
flagsHelp =
ImGuiTabItemFlags_None;


// Top right window buttons
ImVec2 topCursorPos =
ImGui::GetCursorPos ();
Expand Down
2 changes: 0 additions & 2 deletions src/tabs/library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,6 @@ LaunchGame (app_record_s* pApp)
if (pApp->store == app_record_s::Store::Steam)
cmdLine += L" SKIF_SteamAppId=" + std::to_wstring (pApp->id);

// Trim spaces at the end
SKIF_Util_TrimTrailingSpacesW (cmdLine);

SKIF_Shell_AddJumpList (SK_UTF8ToWideChar (pApp->names.normal),
Expand Down Expand Up @@ -2321,7 +2320,6 @@ DrawGameContextMenu (app_record_s* pApp)
std::wstring linkPath = SK_FormatStringW (LR"(%ws\%ws.lnk)", std::wstring(_path_cache.desktop.path).c_str(), SK_UTF8ToWideChar(name).c_str());
std::wstring linkArgs = SK_FormatStringW (LR"("%ws" %ws)", pApp->launch_configs[0].getExecutableFullPath().c_str(), pApp->launch_configs[0].getLaunchOptions().c_str());

// Trim spaces at the end
SKIF_Util_TrimTrailingSpacesW (linkArgs);

if (pApp->store == app_record_s::Store::Steam)
Expand Down
10 changes: 10 additions & 0 deletions src/utility/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1882,6 +1882,16 @@ SKIF_Util_FindProcessByName (const wchar_t* wszName)
return none;
}

HANDLE
SKIF_Util_GetProcessHandleFromHwnd (HWND hwnd, DWORD dwDesiredAccess)
{
DWORD pid = 0;
if (GetWindowThreadProcessId (hwnd, &pid))
return OpenProcess (dwDesiredAccess, FALSE, pid);

return NULL;
}

bool
SKIF_Util_SaveExtractExeIcon (std::wstring sourcePath, std::wstring targetPath)
{
Expand Down

0 comments on commit d6370c6

Please sign in to comment.