Skip to content

Instantly share code, notes, and snippets.

@Tatsh
Created May 10, 2012 03:37
Show Gist options
  • Save Tatsh/2650891 to your computer and use it in GitHub Desktop.
Save Tatsh/2650891 to your computer and use it in GitHub Desktop.
Echo win32
/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 3
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
Copyright (C) 2008, Tatsh
*/
/* A simple Win32 MessageBox implementation of ECHO. */
#include <windows.h>
int main(int argc, char *argv[]) {
/* In Windows, it is impossible AFAIK to pass a NULL argument before a non-NULL argument. Therefore, do not check if both argv[1] and argv[2] are NULL. */
if (argv[1] == NULL) {
printf("No window title or message specified.\nUsage: %s <window title> <message>\n", argv[0]);
return 1;
}
else if (argv[2] == NULL) {
printf("No message specified.\nUsage: %s <window title> <message>\n", argv[0]);
return 1;
}
else {
/* Show the message box */
MessageBox(0, argv[2], argv[1], MB_ICONINFORMATION | MB_OK);
return 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment