Skip to content

Commit eb19dc9

Browse files
Added MessageBox program
Added the program.
1 parent fc22690 commit eb19dc9

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
messagebox.exe: main.cpp
2+
$(CXX) -o messagebox.exe main.cpp -O2 -s -mwindows

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,17 @@
11
# messagebox
2-
Simply calls MessageBox on Windows and returns the result.
2+
Simply calls MessageBox using the Windows API and returns the result.
3+
4+
This is very useful if you want to set reminders through Task Scheduler, so much so that I don't understand why this isn't a standard app.
5+
6+
## Example usage
7+
The syntax is "messagebox *content* *title* *type*" where `type` is an integer representing various properties of the message box. The full list of message box types and return codes are available in the Microsoft documentation for MessageBox [here](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-messagebox).
8+
9+
```
10+
messagebox "This is the content of the message" "Title" 0
11+
```
12+
13+
Since the result of the messagebox is returned, its value is stored in the `errorlevel` variable.
14+
```bat
15+
start /wait messagebox Continue? Confirm 4
16+
echo %errorlevel%
17+
```

main.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <winuser.h>
2+
#include <cstdlib>
3+
4+
int main(int argc, char** argv) {
5+
return MessageBoxA(
6+
NULL,
7+
argc > 1 ? argv[1] : "",
8+
argc > 2 ? argv[2] : "",
9+
argc > 3 ? atoi(argv[3]) : 0
10+
);
11+
}

0 commit comments

Comments
 (0)