- /* Filename : global.h */
- #pragma once
- #ifndef DLL_INTERNAL
- #ifdef WINCE
- #define DLL_INTERNAL
- #else
- #define DLL_INTERNAL __declspec( dllexport )
- #endif
- #endif
- #pragma warning(once:4996) // 4996编译时的警告信息仅显示一个
- //==========================================================================
- // 常用操作宏
- //==========================================================================
- #define LENGTH(x) sizeof(x)/sizeof(x[0])
- #define MIN(x,y) (((DWORD)(x)<(DWORD)(y))?(x):(y))
- #define MAX(x,y) (((DWORD)(x)>(DWORD)(y))?(x):(y))
- #define ASSERT_ADDRESS(p,size) ASSERT((p)!=NULL && AfxIsValidAddress((p),(size),TRUE))
- #define GET_SAFE_STRING(str) ( (str)?(str):_T("") )
- #define GETFILESIZE(fad) (( (fad).nFileSizeHigh << sizeof(DWORD) ) | (fad).nFileSizeLow)
- // strlen_s 函数
- #ifdef UNICODE
- #define strlen_s wcslen
- #else
- #define strlen_s strlen
- #endif
- // strncpy 函数
- #ifdef UNICODE
- #define strncpy_s wcsncpy
- #else
- #define strncpy_s strncpy
- #endif
- // strncat 函数
- #ifdef UNICODE
- #define strncat_s wcsncat
- #else
- #define strncat_s strncat
- #endif
- // strrchr 函数
- #ifdef UNICODE
- #define strrchr_s wcsrchr
- #else
- #define strrchr_s strrchr
- #endif
- // strchr 函数
- #ifdef UNICODE
- #define strchr_s wcschr
- #else
- #define strchr_s strchr
- #endif
- // stricmp 函数
- #ifdef UNICODE
- #define stricmp_s _wcsicmp
- #else
- #define stricmp_s _stricmp
- #endif
- // sscanf 函数
- #ifdef UNICODE
- #define sscanf_s swscanf
- #else
- #define sscanf_s sscanf
- #endif
- // 句柄是否有效
- #define HANDLE_IS_VALID(h) ( (HANDLE)(h!=NULL) && (HANDLE)(h) != INVALID_HANDLE_VALUE )
- // 关闭句柄
- #define SAFE_CLOSE_HANDLE(h)
- {
- if ( HANDLE_IS_VALID ( h ) )
- {
- CloseHandle ( h );
- h = NULL;
- }
- }
- // 等待事件的 Sleep() 函数
- #define SLEEP_RETURN(x)
- {
- if ( ::WaitForSingleObject ( m_hEvtEndModule, x ) == WAIT_OBJECT_0 )
- return FALSE;
- }
- #define SLEEP_BREAK(x)
- {
- if ( ::WaitForSingleObject ( m_hEvtEndModule, x ) == WAIT_OBJECT_0 )
- break;
- }
- //
- // 全局消息
- //
- enum
- {
- WM_SCAN_BLUETOOTH_DEVICE_FINISHED = WM_USER+0x1000,
- };