dont popout new window for success , emulator optimized successfully . instead show it in already exising window of Apply emulator optimization : 
#include <windows.h>
#include <tlhelp32.h>
#include <iostream>
#include <vector>
#include <string>

#define ID_START_BUTTON 1

// Function prototypes
DWORD_PTR GetAffinityMaskForAllCoresExceptCore0();
bool CheckForRunningProcesses(const std::vector<std::wstring>& processNames);
void CheckAndModifyProcesses(const std::vector<std::wstring>& processNames);
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
void OnStartButtonClick(HWND hwnd);

// Main entry point
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
    // Remove console window
    FreeConsole();

    std::vector<std::wstring> processNames = {
        L"MuMuPlayer.exe",
        L"MuMuVMMHeadless.exe",
        L"Ld9BoxHeadless.exe",
        L"Ld9BoxSVC.exe",
        L"dnplayer.exe",
        L"HD-Player.exe"
    };

    // Step: Check for running processes before creating the window
    if (!CheckForRunningProcesses(processNames)) {
        MessageBox(NULL, "No emulator found.", "Error", MB_ICONERROR);
        return 0; // Exit the application if no emulators are found
    }

    const char CLASS_NAME[]  = "EmulatorOptimizer";

    // Register the window class
    WNDCLASS wc = {};
    wc.lpfnWndProc   = WindowProc;
    wc.hInstance     = hInstance;
    wc.lpszClassName = CLASS_NAME;

    RegisterClass(&wc);
    
    HWND hwnd = CreateWindowEx(
        0,
        CLASS_NAME,
        "Emulator Optimizer", // Changed title to "Emulator Optimizer"
        WS_OVERLAPPEDWINDOW,
        CW_USEDEFAULT, CW_USEDEFAULT, 300, 200,
        NULL,
        NULL,
        hInstance,
        NULL);

    if (hwnd == NULL) {
        return 0;
    }

    ShowWindow(hwnd, nCmdShow);

    // Create the Apply Emulator Optimization button
    CreateWindow(
        "BUTTON",  // Predefined class; Unicode assumed 
        "Apply Emulator Optimization", // Button text
        WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,  // Styles 
        50,         // x position 
        50,         // y position 
        200,        // Button width
        30,         // Button height
        hwnd,       // Parent window
        (HMENU)ID_START_BUTTON,       // Control identifier 
        (HINSTANCE)GetWindowLongPtr(hwnd, GWLP_HINSTANCE),
        NULL);      // Pointer not needed 

    // Message loop
    MSG msg;
    while (GetMessage(&msg, NULL, 0, 0)) {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

    return 0;
}

// Windows Procedure
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
    switch (uMsg) {
        case WM_COMMAND: {
            if (LOWORD(wParam) == ID_START_BUTTON) {
                OnStartButtonClick(hwnd);
            }
            break;
        }
        
        case WM_DESTROY:
            PostQuitMessage(0);
            return 0;

        default:
            return DefWindowProc(hwnd, uMsg, wParam, lParam);
    }
    return 0;
}

// Function to calculate affinity mask for all cores except core 0
DWORD_PTR GetAffinityMaskForAllCoresExceptCore0() {
    SYSTEM_INFO sysInfo;
    GetSystemInfo(&sysInfo);
    DWORD_PTR mask = 0;

    // Set bits for all cores except core 0
    for (DWORD i = 1; i < sysInfo.dwNumberOfProcessors; i++) {
        mask |= (1ULL << i);
    }

    return mask;
}

// Function to check if any of the specified processes are running
bool CheckForRunningProcesses(const std::vector<std::wstring>& processNames) {
    HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
    if (hSnapshot == INVALID_HANDLE_VALUE) {
        return false;
    }

    PROCESSENTRY32 pe32;
    pe32.dwSize = sizeof(PROCESSENTRY32);
    
    bool found = false;

    if (Process32First(hSnapshot, &pe32)) {
        do {
            std::wstring exeFileName(pe32.szExeFile, pe32.szExeFile + strlen(pe32.szExeFile));
            for (const auto& processName : processNames) {
                if (exeFileName == processName) {
                    found = true;
                    break;
                }
            }
            if (found) break;
        } while (Process32Next(hSnapshot, &pe32));
    }

    CloseHandle(hSnapshot);
    return found;
}

// Function to monitor and modify specific processes
void CheckAndModifyProcesses(const std::vector<std::wstring>& processNames) {
    DWORD_PTR affinityMask = GetAffinityMaskForAllCoresExceptCore0();
    bool optimized = false; // Flag to check if optimization was successful

    HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
    if (hSnapshot == INVALID_HANDLE_VALUE) {
        MessageBox(NULL, "Failed to create process snapshot.", "Error", MB_ICONERROR);
        return;
    }

    PROCESSENTRY32 pe32;
    pe32.dwSize = sizeof(PROCESSENTRY32);

    if (Process32First(hSnapshot, &pe32)) {
        do {
            std::wstring exeFileName(pe32.szExeFile, pe32.szExeFile + strlen(pe32.szExeFile));

            for (const auto& processName : processNames) {
                if (exeFileName == processName) {
                    HANDLE hProcess = OpenProcess(PROCESS_SET_INFORMATION, FALSE, pe32.th32ProcessID);
                    if (hProcess) {
                        if (SetProcessAffinityMask(hProcess, affinityMask)) {
                            optimized = true; // Set flag if at least one process optimization was successful
                        }
                        CloseHandle(hProcess);
                    }
                }
            }
        } while (Process32Next(hSnapshot, &pe32));
    }

    CloseHandle(hSnapshot);
    
    // Show message if any process was optimized
    if (optimized) {
        MessageBox(NULL, "Emulator optimized successfully.", "Success", MB_OK);
    }
}

// Event handler for button click
void OnStartButtonClick(HWND hwnd) {
    std::vector<std::wstring> processNames = {
        L"MuMuPlayer.exe",
        L"MuMuVMMHeadless.exe",
        L"Ld9BoxHeadless.exe",
        L"Ld9BoxSVC.exe",
        L"dnplayer.exe",
        L"HD-Player.exe"
    };

    // Check and modify processes
    CheckAndModifyProcesses(processNames);
}