Looking to learn Win32, any tips would be appreciated
2 13 Sep 2016 04:10 by u/juggornot
Hi there. I would consider myself an "intermediate" programmer. I have lost a lot of interest in programming, but I keep coming back to where I left off, which is Win32. I have a few questions on where to start learning it as I would like to try.
I know Win32 is a C API, but I do not know C, only C++. Will this cause any issues? The online tutorials I have looked at say no, but I'd like to be sure before I get in way over my head.
Does anyone have tutorials they'd recommend? I've been linked to some decent ones and have also been told to read this, which seems like a good starting place.
Are there any common pitfalls that someone new to win32 programming might fall into that you can think of?
Thank you for your answers. To answer the obvious question: no, I am not interested in learning something else. I'm doing this out of interest, not practicality.
7 comments
2 u/durchfall 13 Sep 2016 08:10
Once you get your head around the basics, is not too hard. Msdn is an excellent resource once you reach that level. One issue that might come to bite you in the ass is all the #defines.
For example, if you make a member function named "CreateWindow", it will actually end up being named CreateWindowW or CreateWindowA if you include windows.h.
Unicode in Windows is utf16, which brings a potential of obscure bugs if you fail to consider surrogate paid (aka emojis will fuck up your sit)
1 u/tame 13 Sep 2016 05:53
Win32 is about a million years old and is not how Windows application development is done nowadays. So I've got two answers for you depending on why you want to go back to Win32.
1) If you have a specific reason to use Win32 (ie. you specifically want to target Windows 95 for some reason): Win32 is easy to access from C++, you can just call the API functions directly. Back in the day I started out with a book (Sams Teach Yourself Windows 95 Programming or something like that) and from there just figured it out from the API documentation, Win32 is pretty straightforward once you get your head around message loops, handles, events etc. and the documentation is great.
2) I know you said you're not interested in learning something else, but Win32 isn't going to be around much longer and unless you want to be stuck in the past like those Amiga guys, it's worth trying something newer. These days I use wxWidgets for my Windows development, it's a (very well designed IMO) C++ library which started out as a wrapper for the Win32 API and so will be familiar to you from the start, and it's just nicer than raw Win32. Kind of like what MFC should have been. Plus you get cross-platform capability and future-proofing for free.
2 u/Atarian 13 Sep 2016 08:34
Hey! Amiga's the future, man.
0 u/rwbj 13 Sep 2016 05:26
C is a subset of C++. You're fine there.
But what exactly do you want to accomplish? Win32 is mostly a tool and one who's functionality is now taken care of automatically in most modern IDEs. I programmed in Win32 for years and couldn't even begin to write the basic code for just having a simple window on screen. It's full of strange conventions, variable names like lpfnWndProc, and borderline arbitrary typedefs of typedefs of typedefs like WPARAM and LPARAM (don't you dare mix up the purpose of those two highly descriptive type names either!) enough to leave you having no idea the types you're dealing with. And in fact in many cases it's okay to have no idea as there will be parameters and other things that literally are just no longer used.
The entire API dates back to 16bit days. Instead of rewriting it as technology changed they just kept patching and adding onto it which in part is why it's so poorly designed. I think it could still be a good exercise in learning how an event driven messaging system works under the hood, but the entire API is a pitfall. Even when you know what you're doing you'll be spending 80% of your time on MSDN and 20% writing code. I would recommend free online tutorials over books in this case. There's always lots of little gotchas in things like this when developing direct Win32 on modern OS's on modern hardware. Types change, those variables that are no longer used were used at one time, and so on. Good luck!
0 u/roznak 13 Sep 2016 19:22
It is not clear what you want to do. But I assume you want to create dll's?
If you have Visual Studio and create a C/C++ application then you are basically already in Win32/64