I have an application where i have created a thread which must check the database for a specific type of data for a timeout interval. The thread is fully responsible for creating the database connection, query and closing the connection. I make the CoInitialize call only once , in the thread execution and i reused the Ado connection and Ado Query for subsequent use .
Now my question is , I had previously ( perhaps erroneously) left a CoUnitialize statement in the loop for database data checking. which means , that the call to CoUnitialize was done every time . Why did the application did not crash ? As there was no data to release CoUnitialize should have failed. I am doubtful on this .
Thanks in Advance
CoUninitializeis a WinApi function that takes nothing and returns nothing. Since those WINAPI functions never throw an exception (AFAIK), your application will not crash by calling them.CoUnitializewill just silently fail when called too many times.Your application could crash afterwards though, when code is called that needs an initialized COM. That your application does not crash can mean two things: the code doesn’t need
CoInitialize, or somewhere elseCoInitializeis called, maybe in your ADO library.