Category Archives: Windows programming tips

HOWTO detect WIN11 using Windows API

The main problem here is that Windows 11 is a Windows 10++, and there is no function like IsWindows10OrGreater(). This forced us to write down our own IsWindows11OrGreater(). I want to write a function similar to the existing IsWindows*() using VerifyVersionInfo(). Here is the working body of such a function: BOOL IsWindows11OrGreater() { OSVERSIONINFOEX vi; ULONGLONG conditions; memset (&vi, 0, sizeof(vi)); vi.dwOSVersionInfoSize = sizeof(vi); vi.dwMajorVersion … Continue reading HOWTO detect WIN11 using Windows API »

HOWTO use NASM function for Windows 64-bits

Writing 64-bits assembler functions for Windows is quite different from the ones written for Linux or even for Windows 32 bits. Even when using NASM for a simplified approach, you shall care about a few details. First steps The first step is to add the following lines at the very beginning of the .asm file: 64 bits default rel We need the ‘default rel’ to … Continue reading HOWTO use NASM function for Windows 64-bits »

HOWTO convert a .rc file to VC++ flavored one

Recently I was in need to import a resource file (.rc) generated by ResEdit program into a Visual C++ program. As long you do not open it with the VC embedded editor, only can only add it to the project. Problems came when you try to use the embedded VC resource editor.  It usually fails to load, because of a problem in prsht.h.  I don’t … Continue reading HOWTO convert a .rc file to VC++ flavored one »

HOWTO include Visual C++ RTL in a Inno Setup kit

Introduction Compiling our programs using external RTLs is generally always a good option to have smaller & efficient programs. In the case of Visual Studio ones, the best option is to use its own setup kit, because: it frees us from caring about RTL requirements (needed files, components registrations, …) from Visual Studio 2015 to 2022, it is a single standard package. once installed, it … Continue reading HOWTO include Visual C++ RTL in a Inno Setup kit »

HOWTO uninstall a program from Inno Setup kit

Introduction One of the many challenges in releasing the latest version of Horodruin was that the main edition switched to 64-bits. This means that we cannot simply install/update the new program over the existing one, mainly because 64 bits programs have a different default system folder (‘Program Files‘) than 32 bits ones (‘Program Files (x86)‘). The best option here is to uninstall the old one, … Continue reading HOWTO uninstall a program from Inno Setup kit »

A custom EVENT object for lighting fast thread synchronization

Several weeks ago, while I was working on the next version of Horodruin, I was optimizing the multithreaded file copy engine. This optimization phase pops up an unexpected event on the standard event object processing.  It seems that frequent uses of SetEvent() API are not exactly processing-resources free. This is probably caused by some code overhead needed for a system object… During these evaluations, I … Continue reading A custom EVENT object for lighting fast thread synchronization »

HOWTO easily use NASM into windows C/C++ applications

After installed NASM and configured our VisualStudio to use it, we are now able to use it in our C/C++ projects. Assembler usually has a huge advantage in terms of performance at the cost of rigid code usage. You cannot use it in both 32-bits and 64-bits versions of the same C/C++ code.  Each version shall fulfill several different ‘environmental’ requirements that cannot be ignored … Continue reading HOWTO easily use NASM into windows C/C++ applications »

Few Considerations About Functions Returning an Object

I am rewriting a VCL program using MFC, and I have converted many functions of this kind: CString MyFunction () { return L”Sample test”; } This kind of function declaration is comfortable, but the question is: is it also convenient?   The answer I found is that it might not be so convenient, especially if used inside a loop. When we call this function, we … Continue reading Few Considerations About Functions Returning an Object »

HOWTO Make Windows SlimRW Lock More Confortable

Recently I tripped into SlimRW Lock API. It’s a Windows synchronization object very similar to the critical section, with the support of two different types of lock: shared and exclusive. Essentially you should get the shared lock for all read-only activities, while the exclusive lock shall be used for all the other cases. The Basic Implementation I wrote this simple class to include them in … Continue reading HOWTO Make Windows SlimRW Lock More Confortable »

HOWTO Automatically Catch Problems While Debugging

Suppose to have the ability to add dozens of breakpoints into your program main error detection points, whenever you start a debugging session. This should allow you to easily track down some hidden/unnoticed problems. For example, suppose to have a C function like the below one: __MYOBJECTDATA * WINAPI MYOBJGetPtr (HANDLE hMyObject) { __MYOBJECTDATA *pObj; pObj = (__MYOBJECTDATA *) hMyObject; __try { if ((pObj != … Continue reading HOWTO Automatically Catch Problems While Debugging »