Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8467797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:44:56+00:00 2026-06-10T15:44:56+00:00

I am creating a DLL to check when the user presses the close button

  • 0

I am creating a DLL to check when the user presses the close button on the application window, it works fine, then I want to do it so that when _text global variable is empty, no message will be shown.
I can’t understand why a simple if (_text != “”) doesn’t work… am I doing something wrong?

#include <windows.h>
#define export extern "C" __declspec (dllexport)

WNDPROC GameWndProc = NULL;
HWND GameHwnd = NULL;
double _button_result = 0;
char* _text;
char* _title;

LRESULT CALLBACK SubClassWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch(uMsg) {
        case WM_CLOSE:

            if (_text != "") {
                if (MessageBox(GameHwnd, (LPSTR)_text, (LPSTR)_title, MB_YESNO|MB_APPLMODAL) == IDYES) {
                    _button_result = 1;
                    return 0;
                } else {
                    return 0;
                }
            }           

            _button_result = 1;
            return 0;
        break;
    }

    return CallWindowProc(GameWndProc, hwnd, uMsg, wParam, lParam);
}

export double _window_check_close_init(double window_handle, char* _msg_text, char* _msg_title)
{
    GameHwnd = (HWND)(int)window_handle;
    GameWndProc = (WNDPROC)SetWindowLongPtr(GameHwnd, GWL_WNDPROC, (LONG)SubClassWndProc);
    _text = _msg_text;
    _title = _msg_title;

    if (!GameWndProc) {
        return 0;
    }

    return 1;
}

export double _window_check_close()
{
    if (_button_result == 1) {
        _button_result = 0;
        return 1;
    } else {
        return 0;
    }
}

BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
    if (fdwReason == DLL_PROCESS_DETACH) {
        if (IsWindow(GameHwnd) && GameWndProc) {
            SetWindowLongPtr(GameHwnd, GWL_WNDPROC, (LONG)GameWndProc);
        }
    }
    return TRUE;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T15:44:57+00:00Added an answer on June 10, 2026 at 3:44 pm

    You’re checking if the pointer _text is equal to the empty string, not if the string pointed to by _text is equal to the empty string. You probably want to do something like:

    if (strlen(_text) !=0)
    ... rest of your code...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When creating DLL files for a program that already exists, is it customary to
I'm creating a C api that hides some functionality in a DLL file. Since
We are creating a WCF service with a companion client DLL (.Net) that we
I have a WPF project (creating dll). The text boxes that added, (or the
I'm creating a DLL in Delphi that must have the following C++ structure. DWORD
I need help creating a .dll file from a custom control so that it
I'm creating an application that need a nice GUI and some openGL rendering (I
I`m creating a cast of dlls that shares a single dll. The shared lib
Beyond creating a dll with all the same functions with the same interface and
I am creating a C# dll, which will be called by RIA services, which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.