「C言語/C++/文字セット(Windows)」の編集履歴(バックアップ)一覧に戻る

C言語/C++/文字セット(Windows) - (2012/09/10 (月) 22:17:29) のソース

|開発環境|Microsoft Visual C++ 2010 Express (SP1)|
|実行環境|Microsoft Windows XP Home Edition (SP3)|
|プロジェクトの種類|Win32 プロジェクト|
|プロジェクト名|WinTest|
|アプリケーションの種類|Windows アプリケーション|
|追加のオプション|空のプロジェクト|

Windowsで使われる文字(列)の型
|型名|定義|型名の元となったと思われるもの|
|CHAR|char|Character|
|WCHAR|wchar_t|Wide Character|
|TCHAR|CHAR / WCHAR|Text Character|
|LPSTR|CHAR *|Long Pointer String|
|LPWSTR|WCHAR *|Long Pointer Wide character String|
|LPTSTR|LPSTR / LPWSTR|Long Pointer TCHAR String|
|LPCSTR|const CHAR *|Long Pointer Constant String|
|LPCWSTR|const WCHAR *|Long Pointer Constant Wide character String|
|LPCTSTR|LPCSTR / LPCWSTR|Long Pointer Constant TCHAR String|

参考
[[What are TCHAR, WCHAR, LPSTR, LPWSTR, LPCTSTR (etc.)?>http://www.codeproject.com/Articles/76252/What-are-TCHAR-WCHAR-LPSTR-LPWSTR-LPCTSTR-etc]]

----
マルチ バイト文字セット(Multi Byte Character Set)対応

WinTest_mbcs.c
#highlight(c){{
// マルチ バイト文字セット
#include <Windows.h>

int APIENTRY WinMain(
	HINSTANCE hInstance,
	HINSTANCE hPrevInstance,
	LPSTR lpCmdLine,
	int nCmdShow)
{
	MessageBox(NULL, lpCmdLine, "Caption", MB_OK);
	return 0;
}
}}

----
Unicode 文字セット(Unicode Character Set)対応

WinTest_ucs.c
#highlight(c){{
// Unicode 文字セット
#include <Windows.h>

int APIENTRY wWinMain(
	HINSTANCE hInstance,
	HINSTANCE hPrevInstance,
	LPWSTR lpCmdLine,
	int nCmdShow)
{
	MessageBox(NULL, lpCmdLine, L"Caption", MB_OK);
	return 0;
}
}}

----
Unicode 文字セット(Unicode Character Set)対応

WinTest_text.c
#highlight(c){{
// Unicode 文字セット
#include <Windows.h>

int APIENTRY wWinMain(
	HINSTANCE hInstance,
	HINSTANCE hPrevInstance,
	LPTSTR lpCmdLine,
	int nCmdShow)
{
	MessageBox(NULL, lpCmdLine, TEXT("Caption"), MB_OK);
	return 0;
}
}}

----
両文字セット対応

WinTest_tchar.c
#highlight(c){{
#include <tchar.h>
#include <Windows.h>

int APIENTRY _tWinMain(
	HINSTANCE hInstance,
	HINSTANCE hPrevInstance,
	LPTSTR lpCmdLine,
	int nCmdShow)
{
	MessageBox(NULL, lpCmdLine, _T("Caption"), MB_OK);
	return 0;
}
}}