Last active
January 30, 2025 15:45
-
-
Save ricardojoserf/effe7a8c9f68ff78ac0a60e1b6b18410 to your computer and use it in GitHub Desktop.
user32!MessageBoxA function in Matlab
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if not(libisloaded('user32')) | |
| loadlibrary('user32.dll', @user32proto); | |
| end | |
| hWnd = uint32(0); | |
| lpText = 'Hello from MATLAB'; | |
| lpCaption = 'MATLAB MessageBox'; | |
| uType = uint32(0); | |
| result = calllib('user32', 'MessageBoxA', hWnd, lpText, lpCaption, uType); | |
| disp(['MessageBox returned: ', num2str(result)]); | |
| unloadlibrary('user32'); | |
| function [fcns, structs, enuminfo] = user32proto | |
| fcns = []; structs = []; enuminfo = []; fcns.alias = {}; | |
| % Prototype for MessageBoxA | |
| fcns.name{1} = 'MessageBoxA'; | |
| fcns.calltype{1} = 'cdecl'; % Correct calling convention for Windows API | |
| fcns.LHS{1} = 'uint32'; % Return type is an unsigned integer | |
| fcns.RHS{1} = {'uint32', 'cstring', 'cstring', 'uint32'}; % Argument types | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment