VC++判断操作系统bit

//source: http://stackoverflow.com/questions/23696749/how-to-detect-on-c-is-windows-32-or-64-bit

#include <windows.h>
#include <iostream>
#include <tchar.h>

BOOL IsWow64()
{
	BOOL bIsWow64 = FALSE;

	typedef BOOL(WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
	LPFN_ISWOW64PROCESS fnIsWow64Process;
	fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle(TEXT("kernel32")), "IsWow64Process");


	if (NULL != fnIsWow64Process)
	{
		if (!fnIsWow64Process(GetCurrentProcess(), &bIsWow64))
		{
			//handle error
		}
	}
	return bIsWow64;
}

int main()
{
	if (IsWow64())
		wprintf(TEXT("The process is running under Windows 64.\n")); //是64位操作系统
	else
		wprintf(TEXT("The process is NOT running under Windows 64.\n")); //不是64位操作系统
}


std::wstring转wchar_t

#include <string>
#include <iostream>

using namespace std;

int main(int argc,char* argv[])
{
	wstring str = L"aaa";
	wchar_t *mystr = (wchar_t *)str.c_str();

	wcout << mystr << endl;

	return 0;
}


最终输出结果:

aaa

C++ DirectX获取当前FPS

float Get_FPS()
{
	static float fps = 0.0f;
	static int frameCounts = 0;
	static float currentTime = 0.0f;
	static float lastTime = 0.0f;

	frameCounts++;

	currentTime = timeGetTime() * 0.001f;

	if(currentTime - lastTime > 1.0f)
	{
		fps = float(frameCounts) / (currentTime - lastTime);
		lastTime = currentTime;
		frameCounts = 0;
	}

	return fps;
}