Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

thread: remove win32 SetThreadDescription #768

Merged
merged 1 commit into from
Apr 15, 2023
Merged

thread: remove win32 SetThreadDescription #768

merged 1 commit into from
Apr 15, 2023

Conversation

sreimers
Copy link
Member

@sreimers sreimers commented Apr 15, 2023

only available on newer systems

@sreimers sreimers changed the title thread: remove win32 SetThreadDescription (only available on newer sy… thread: remove win32 SetThreadDescription Apr 15, 2023
@sreimers sreimers merged commit 1f34fbb into main Apr 15, 2023
@sreimers sreimers deleted the thread_mingw branch April 15, 2023 19:34
@paresy
Copy link
Contributor

paresy commented May 4, 2023

Hi! I have just seen this commit and wanted to share some code, that we use in another project to automatically detect availability of this function:

    // SetThreadDescription is only available on Windows 10 and later
    using SetThreadDescription_t = decltype(&SetThreadDescription);

    const HMODULE hKernel = GetModuleHandle("KernelBase.dll");
    if (hKernel == nullptr) {
        return;
    }

    const auto SetThreadDescription_p = reinterpret_cast<SetThreadDescription_t>(GetProcAddress(hKernel, "SetThreadDescription"));
    if (SetThreadDescription_p == nullptr) {
        return;
    }

    auto wName = std::wstring(Name.begin(), Name.end());

    SetThreadDescription_p(GetCurrentThread(), wName.c_str());

Maybe this helps to bringt back this function 😄

KORuL pushed a commit to KORuL/re that referenced this pull request May 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants