Skip to content

Commit

Permalink
Use new last_error() function
Browse files Browse the repository at this point in the history
  • Loading branch information
eschan145 committed Jan 17, 2025
1 parent a22104e commit 4e5c1ff
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@ DK_API const char* get_folder_path() {
return FOLDER_PATH;
}

std::string last_error() {
return std::to_string(GetLastError());
}

bool taskkill(DWORD identifier) {
HANDLE process = OpenProcess(PROCESS_TERMINATE, FALSE, identifier);

Expand All @@ -312,7 +316,7 @@ void CALLBACK sweep(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) {

if (snapshot == INVALID_HANDLE_VALUE) {
error("Failed to produce a snapshot with CreateToolHelp32! Error " +
"code: " + std::to_string(GetLastError()) + "\n");
"code: " + last_error() + "\n");
return;
}

Expand Down Expand Up @@ -340,8 +344,8 @@ void CALLBACK sweep(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) {
}
} while (Process32Next(snapshot, &pe32));
} else {
error("Failed to enumerate processes! Error code: " +
std::to_string(GetLastError()) + "\n");
error("Failed to enumerate through processes! Error code: " +
last_error() + "\n");
}
}

Expand Down

0 comments on commit 4e5c1ff

Please sign in to comment.