MsWindows.h

// MsWindows.h
//
// Author David Barrett-Lennard
// (C)opyright Cedanet Pty Ltd 2013

#pragma once
#ifndef Ceda_cxUtils_MsWindows_H
#define Ceda_cxUtils_MsWindows_H

#include "cxUtils.h"

#ifdef _WIN32
    #ifdef WINCE
        #pragma comment(linker, "/nodefaultlib:libc.lib")
        #pragma comment(linker, "/nodefaultlib:libcd.lib")

        // NOTE - this value is not strongly correlated to the Windows CE OS version being targeted
        #define WINVER _WIN32_WCE

        #include <ceconfig.h>
        #if defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP)
        #define SHELL_AYGSHELL
        #endif

        #ifdef _CE_DCOM
        #define _ATL_APARTMENT_THREADED
        #endif

        #ifdef SHELL_AYGSHELL
        #include <aygshell.h>
        #pragma comment(lib, "aygshell.lib") 
        #endif // SHELL_AYGSHELL

        // Windows Header Files:
        #define NOMINMAX
        #include <windows.h>

        #if defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP)
        #ifndef _DEVICE_RESOLUTION_AWARE
        #define _DEVICE_RESOLUTION_AWARE
        #endif
        #endif

        #ifdef _DEVICE_RESOLUTION_AWARE
        #include "DeviceResolutionAware.h"
        #endif

        #if _WIN32_WCE < 0x500 && ( defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP) )
            #pragma comment(lib, "ccrtrtti.lib")
            #ifdef _X86_	
	            #if defined(_DEBUG)
		            #pragma comment(lib, "libcmtx86d.lib")
	            #else
		            #pragma comment(lib, "libcmtx86.lib")
	            #endif
            #endif
        #endif

        #include <altcecrt.h>

    #else // not WINCE

        // windows.h includes winsock.h itself, therefore, if you include winsock2.h after it, 
        // several redefinition conflicts arise.
        // If you want to use the winsock2 api, you must include winsock2.h before windows.h. 
        // Also make sure that no other headers include windows.h before winsock2.h.
        //#include <winsock2.h>

        #ifndef WIN32_LEAN_AND_MEAN
            // Define WIN32_LEAN_AND_MEAN to exclude APIs such as Cryptography, DDE, RPC, Shell, and Windows Sockets.
            // Problem : this upsets gdi+
            #define WIN32_LEAN_AND_MEAN
        #endif

        #ifndef STRICT
            // Enable strict type-checking of Windows handles
            #define STRICT                  
        #endif

        #ifndef NOMINMAX
            #define NOMINMAX
        #endif
        #include <algorithm>
        namespace Gdiplus
        {
            using std::min;
            using std::max;
        }
        #include <windows.h>

        #ifdef _M_X64
        #include <math.h>      // To avoid warning due to Microsoft bug - math.h should be before intrin.h
        #endif
    #endif // WINCE

    namespace ceda
    {
        class xostream;
        cxUtils_API void WriteWindowsErrorMessage(xostream& os, DWORD errorCode);

        cxUtils_API void TraceWindowsError();
    } // namespace ceda

#endif // _WIN32

#endif // include guard