// MySQLAPITest.cpp : Defines the entry point for the console application. // #include "stdafx.h" // requires >=winxp SP1 #define _WIN32_WINNT 0x0501 #include #include #include #include "mysql.h" // link dll-stub #pragma comment(lib, "libmysql.lib") int _tmain(int argc, _TCHAR* argv[]) { unsigned option; DWORD hCount; // handle to us HANDLE hProcess=GetCurrentProcess(); printf("\r\nmysql_thread_safe() returns: ': %d",mysql_thread_safe()); for (int i=1; i<6; i++){ printf("\r\n*****************************************************"); printf("\r\nrun %d",i); printf("\r\n*****************************************************"); // count handle resources GetProcessHandleCount(hProcess,&hCount); printf("\r\nHandle count before 'mysql_init(NULL)':\t\t%d",hCount); MYSQL* hmysql=mysql_init(NULL); GetProcessHandleCount(hProcess,&hCount); printf("\r\nHandle count after 'mysql_init(NULL)':\t\t%d",hCount); option=MYSQL_PROTOCOL_MEMORY; mysql_options(hmysql,MYSQL_OPT_PROTOCOL,(char*)&option); GetProcessHandleCount(hProcess,&hCount); printf("\r\nHandle count before 'mysql_real_connect(...)':\t%d",hCount); mysql_real_connect(hmysql,"localhost","root","","",0,NULL,CLIENT_MULTI_STATEMENTS); GetProcessHandleCount(hProcess,&hCount); printf("\r\nHandle count after 'mysql_real_connect(...)':\t%d",hCount); mysql_close(hmysql); GetProcessHandleCount(hProcess,&hCount); printf("\r\nHandle count after 'mysql_close(...)':\t\t%d",hCount); mysql_thread_end(); GetProcessHandleCount(hProcess,&hCount); printf("\r\nHandle count after 'mysql_thread_end():\t\t%d\r\n'",hCount); } return ERROR_SUCCESS; }