Tag: ATL

Thread synchronization and context switches

A basic task in thread synchronization is putting something on one thread and getting it out on another thread for further processing. Two or more threads of execution are accessing certain data, and in order to keep data consistent and solid the access is split into atomic operations which are only allowed for one thread…

Read the full article

Recursive SRW Locks

Windows Vista added new synchronization API, Slim Reader/Writer (SRW) Locks, which is a powerful alternative to critical sections. The detailed description is, as always on MSDN, and what makes it really cool is simple: unlike critical sections, SRW Locks provide reader and writer access synchronization making it possible for 2 and more reader to not…

Read the full article

How to get HMODULE of msvcr90.dll

Because Microsoft C++ Runtime library is distributed as a side-by-side assembly, GetModuleHandle and LoadLibrary is no longer available to locate the library within the process. Both API calls would return NULL handle. HMODULE hModule = GetModuleHandle(_T(“msvcr90.dll”)); HMODULE hModule = LoadLibrary(_T(“msvcr90.dll”)); Still, how to locate the modules in order to, for example, be able to check…

Read the full article

Attributed ATL: Accessing BLOB with ISequentialStream

Before attributed ATL was deprecated, it was a convenient way to access databases using attributed classes on top of OLEDB Consumer Templates. Does not it look nice? [ db_command(“SELECT ServerData FROM Server WHERE Server = ?”) ] class CGetServerData { public: [ db_param(1) ] LONG m_nServer; [ db_column(1, length = “m_nDataLength”) ] ISequentialStream* m_pDataStream; DBLENGTH…

Read the full article