Skip to content

Commit

Permalink
Initial import
Browse files Browse the repository at this point in the history
  • Loading branch information
sjmulder committed Aug 6, 2017
1 parent 5e810c3 commit d720c94
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.vs/
*.swp
*.swo
*.obj
*.exe
7 changes: 7 additions & 0 deletions build_cl.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@set CC=cl
@set CFLAGS=/nologo /O1
@set LDFLAGS=/nodefaultlib /subsystem:windows /entry:WinMainCRTStartup
@set LDLIBS=kernel32.lib user32.lib
@set TARGET=closeall.exe

%CC% %CFLAGS% /Fe:%TARGET% *.c /link %LDFLAGS% %LDLIBS%
9 changes: 9 additions & 0 deletions build_gcc.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@echo off

set CC=gcc
set CFLAGS=-ansi -Wall -nostdlib -ffreestanding -Os -s
set LDFLAGS=-mwindows -s
set LDLIBS=-lkernel32 -luser32
set TARGET=closeall.exe

%CC% %CFLAGS% %LDFLAGS% -o %TARGET% *.c %LDLIBS%
17 changes: 17 additions & 0 deletions closeall.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <windows.h>

static BOOL CALLBACK EnumProc(HWND hwnd, LPARAM lParam)
{
if ((GetWindowLong(hwnd, GWL_STYLE) &
(WS_VISIBLE|WS_OVERLAPPEDWINDOW|WS_CHILD)) ==
(WS_VISIBLE|WS_OVERLAPPEDWINDOW))
PostMessage(hwnd, WM_CLOSE, 0, 0);

return TRUE;
}

void WinMainCRTStartup(void)
{
EnumWindows(EnumProc, 0);
ExitProcess(0);
}

0 comments on commit d720c94

Please sign in to comment.