Creating a log file in Windows Runtime using C++

If you have a native C++ project running on Windows Runtime AND you want to do some logging then you are in for a surprise. You cannot simply open a file “C:\log.txt” and dump all your logs there. You have to use Windows Runtime APIs to create files and write to them. Since Windows Runtime…

3

Best method for Critical Section management in C++

When it comes down to using critical sections in your C++ code you have pretty much standard options. Simply call “EnterCriticalSection” at the start of your function and call “LeaveCriticalSection” at the end of your function. No doubt things will work fine, but this approach is not going to be very scalable. Look at the…


C++ Converting ComPtr<IRandomAccessStream> to ComPtr<IClosable>

When using WRL, sometimes if you have a pointer to derived interface such as IRandomAccessStream (which derives from IClosable), and you would want to convert it to IClosable (so that you can call “Close” on the stream). To do that you will have to use ComPtr.As call. Example:  WRL::ComPtr< Streams::IRandomAccessStream > randomAccessStream; // set randomAccessStream…

1

Calling Windows Runtime Async functions from C++ using WRL

“await” This 5 letter word might look trivial to you if you are a C# developer, but once you leave C# domain and enter the cruel world of C++/CX you will start to like it. But if you move to pure C++ from C++/CX then you will start to love it. Reason for that is…


HSTRING wrapper for C++

If you are developing apps for Windows Store or Windows Phone in C++, chances are that one of the biggest annoyance you will see are the HSTRING(specifically creating and managing them.) If you are using C++/CX you can get away by using “Platform::String”, but if you cannot use CX extension your only option is to…