第一个SDK程序

#include

int WINAPI WinMain(HINSTANCE hInstance,
	HINSTANCE hPrevInstance,
	LPSTR lpCmdLine,
	int nShowCmd){/*单字节版本*/

	MessageBoxA(NULL, "HelloWolrd!", "title", MB_OK);

	return 0;
}

/*
1.使用的是单字节版本
2.LPSTR == char *
3.MessageBoxA为单字节版本,MessageBoxB为双字节版本
*/

#include

int WINAPI wWinMain(HINSTANCE hInstance,
	HINSTANCE hPrevInstance,
	LPWSTR lpCmdLine,
	int nShowCmd){/*双字节版本*/

	MessageBoxW(NULL, L"HelloWolrd!", L"title", MB_OK);

	return 0;
}

#include
#include

int WINAPI _tWinMain(HINSTANCE hInstance,
	HINSTANCE hPrevInstance,
	LPTSTR lpCmdLine,
	int nShowCmd){/*兼容版本*/

	MessageBox(NULL, _T("张玉尧,你好!"), _T("标题"), MB_OK);

	return 0;
}


#include
#include

int WINAPI _tWinMain(
	HINSTANCE hInstance,
	HINSTANCE hPrevInstance,
	LPTSTR lpCmdLine,
	int nShowCmd){/*练习使用wsprintf函数(实际上也是一个宏)*/
	int i, sum = 0;
	TCHAR str[10];
	for(i = 1; i <= 100; i++){
		sum += i;
	}
	wsprintf(str, "%d", sum);
	MessageBox(NULL, str, _T("1+2+...+100"), MB_OK);
	return 0;
}

你可能感兴趣的:(C)