Windows Implementation Libraries: type-safe C++ interfaces for Windows patterns
github.com
github.com
Microsoft has been shipping a C++ compiler for decades, and for the most part it is the preferred language for Windows development even today.
Moreover, there have been PLENTY of libraries designed to make it easier, like MFC, ATL, etc.
Why didn’t this already exist?!
Like I realize some of it is modern C++ and maybe Microsoft was not focusing on desktop when C++ had these innovations. But why not smart pointers for handles, error handling macros, etc. Crazy.
Lateness aside, I still occasionally do write win32 stuff, usually to extend/compliment/hack upon existing win32 stuff. So this is probably going to become a goto library now, if its as good as it sounds.
This is basically it, I think; COM and HANDLEs predate working standardised C++ compilers. MFC provides higher-level abstractions. Then everyone got distracted by managed runtimes. Finally C++ has a mostly-sane framework for universal usage of smart pointers, so this is bringing them back to the old Win32 era.
Unfortunately we can't get rid of wstring, but we can provide yet another layer of wrappers for it.
Boost's smart pointers have apparently [2] been around for about as long.
If people have been rolling their own smart pointers since that time, isn't that their own fault?
[0] https://docs.microsoft.com/en-us/cpp/atl/reference/ccomptr-c...
[1] https://en.wikipedia.org/wiki/Active_Template_Library#Histor...
[2] https://www.boost.org/doc/libs/1_31_0/libs/smart_ptr/smart_p...
If your question was "why wasn't a C++ wrapper released sooner?" I think the answer is ".NET". If your question was "why didn't the API's have C++ semantics?" I think the answer is "because a lot of it is C, not C++."
It was a big improvement when we standardized on this library across all the teams. I can’t recommend this enough.
My experience with Win32 apps using those (mostly from the perspective of modifying existing code, not starting from scratch) is that they made it easy to create something quickly to meet the initial requirements, but then the increased abstraction later gets in the way of debugging and extending. I suspect this effect is general to all libraries and frameworks that attempt to be a layer over an existing one.
Personally, I've found pure C and Win32 to be easy enough, but then again, it's something I've been doing for decades.
It's existed for a while but was never very popular.
Despite a million fancy new API layers in newer versions of Windows, Win32 is very much not dead, but it's still a C interface with a lot of clunky and inconsistent nonsense. This looks like the ideal modern C++ wrapper for all that.
DWORD errorCode = GetLastError();
DWORD dwFlg = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS;
LPTSTR lpMsgBuf = NULL;
FormatMessageA(dwFlg, 0, errorCode, 0, (LPTSTR)&lpMsgBuf, 0, NULL);
// Error message is in lpMsgBuf so make sure to free afterwards.
LocalFree(lpMsgBuf);Nice to see Clang being put to good use on Windows.