#pragma once

#ifdef _DEBUG

	#pragma message( "メモリリーク検査あり" )

	#define _CRTDBG_MAP_ALLOC
	#include <stdlib.h>
	#include <malloc.h>
	#include <crtdbg.h>

#else

	#include <stdlib.h>
	#include <malloc.h>

#endif


#ifdef _UNICODE
#define tstring std::wstring
#define tstringstream std::wstringstream
#else
#define tstring std::string
#define tstringstream std::stringstream
#endif

#ifdef _UNICODE
// Windows2000 + IE6
#define _WIN32_WINNT 0x0500
#else
// Win98/NT4 + IE6
#define _WIN32_WINNT 0x0400
#endif

#define _WIN32_IE 0x600

#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif

#include <windows.h>

#include <winsock2.h>
#include <ws2tcpip.h>
#include <iphlpapi.h>


#include <TCHAR.H>

#include <atlbase.h>
#include <atlconv.h>

#include <string>

// Widows XP以降のビジュアルスタイル
#ifdef _UNICODE
#if defined _M_IX86
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_IA64
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_X64
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#else
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#endif
#endif

// ネイティブスレッドに名前をつけるためのヘルパ
#include "SetThreadName.h"

// Windows XP以降のリストビュー拡張スタイル
#ifndef LVS_EX_DOUBLEBUFFER
#ifdef _UNICODE
#define DBLBUFFER_FLAG 0x00010000
#else
#define DBLBUFFER_FLAG 0
#endif
#else
#define DBLBUFFER_FLAG LVS_EX_DOUBLEBUFFER
#endif

// CPUカウンタによるパフォーマンス計測
#ifdef _DEBUG
inline __int64 __fastcall rdtsc()
{
    __asm {
        cpuid
        rdtsc
    }
}
#else
inline __int64 __fastcall rdtsc()
{
	return 0;
}
#endif
