r/C_Programming • u/Round-Pension-7821 • Aug 02 '26
Project Helpful Windows GUI Program in 60 lines of C
https://github.com/GeorgeTR1/windowsDistractionCoverVery small C program I wrote that I've found genuinely useful. It compiles into a tiny 3 kB executable that only relies on system .dlls included with the operating system. The code should compile and run, with the proper compiler, all the way back to Windows 95.
This could also be useful to anyone looking for how to write a basic GUI program for Windows in C.
63
Upvotes
âĸ
u/github-guard Aug 02 '26
đ GitHub Guard: Trust Report
This project scored 3/6 on our safety audit.
Audit Breakdown:
13
u/skeeto Aug 02 '26
Neat little project. This feels like the sort of window that ought to be draggable from anywhere in the window itself. This will do it:
As was already pointed out, using
mainlike that is incorrect. Your program is not built correctly, causing your trouble return frommain. To get the behavior you actually want name itWinMainCRTStartup, use stdcall, then drop the/entryargument and because it defaults to this function, and also droplibvcruntime.lib:Normally the CRT defines this function, so you need to do so since you don't want to use a CRT. While it's legal to return from this entry point, it's still a good idea to use
ExitProcessor similar to avoid bugs imposed upon your program externally. So then to build should just be:Or Mingw-w64:
(The two
-foptions, both optional, really trim it down since it looks like you care about this.)7
u/mikeblas Aug 02 '26 edited Aug 02 '26
Why use
main()as your entry point instead ofWinMain()? You do specify--subsystem:Windows, but then half-undo that with--entry:main.What you've got works, it's just a bit surprising and cumbersome.
Does your code leak your window handle at exit?
What is it that you're trying to do on double clicks?
1
u/tastygames_official Aug 05 '26
this might also interest anyone interested in low-level windows programming: https://www.youtube.com/watch?v=-Vw-ONPfaFk
1
u/AutoModerator Aug 02 '26
Hi /u/Round-Pension-7821,
Your submission in r/C_Programming was filtered because it links to a git project.
You must edit the submission or respond to this comment with an explanation about how AI was involved in the creation of your project.
While AI-generated code is not disallowed, low-effort "slop" projects may be removed and it's likely that other users push back strongly on substantially AI-generated projects.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
0
u/[deleted] Aug 02 '26
[deleted] â view deleted comment