一个很简单的MC启动器,vs2010环境下程序8k,vs2012下10k,
[cpp]
#include <windows .h>
#include <stdlib .h>
#include <string .h>
#include <tchar .h>
#include <shellapi .h> //需要调用外部程序
#define starts _T("-Xms512m -Xmx1024m -cp .\\.minecraft\\bin\\* -Djava.library.path=.\\.minecraft\\bin\\natives net.minecraft.client.Minecraft ragnaroks")
#define folder _T("C:\\Program Files\\Java\\jre7\\bin\\javaw.exe")
// 主窗口类名
static TCHAR szWindowClass[] = _T("MCL");

// 主窗口标题名
static TCHAR szTitle[] = _T("星战前夜-MC启动器 v0.1 by:ragnaroks");

HINSTANCE hInst;

// 实现函数
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hdc;
int CtrlID=LOWORD(wParam);
TCHAR StaticTip[] = _T("星战前夜-MC启动器,以性能/程序大小/兼容性为优先,使用sdk编写");
TCHAR StaticTip2[]=_T("极限最简化代码,DOS字体,无美化资源及代码,,程序仅10kb");

switch (message)
{
case WM_CREATE: //创建
// 绘制输入区
CreateWindow(_T("button"),_T("请输入启动参数"), WS_CHILD | WS_VISIBLE | BS_GROUPBOX,
5,45,420,100,hWnd,0, ((LPCREATESTRUCT)lParam)->hInstance, NULL );
// 关于按钮
CreateWindow(_T("button"),_T("关于本程序"), WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON,
365,172,96,24,hWnd,(HMENU)1001, ((LPCREATESTRUCT)lParam)->hInstance, NULL );
// 启动按钮
CreateWindow(_T("button"),_T("启动MC"), WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON,
5,172,64,24,hWnd,(HMENU)100, ((LPCREATESTRUCT)lParam)->hInstance, NULL );
break;
case WM_COMMAND:
switch (CtrlID)
{
case 1001:
MessageBox(hWnd,_T("本程序使用win sdk开发,代码质量和运行效率,\n是MFC/VB.net/C#/易语言等无法相比的,\n当然界面美观也没法比…以后再弄吧…\n有问题:Admin@ragnaroks.org"),_T("关于"),NULL);
break;
case 100:
ShellExecute(hWnd,_T("open"),folder,starts,NULL,SW_SHOW);
break;
}
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// 绘制设备上下文
TextOut(hdc,5,5,StaticTip,_tcslen(StaticTip));
TextOut(hdc,5,25,StaticTip2,_tcslen(StaticTip2));
// 结束绘制
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
break;
}
return 0;
}

// 主函数
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
WNDCLASSEX hw;

hw.cbSize = sizeof(WNDCLASSEX); // ??
hw.style = CS_HREDRAW | CS_VREDRAW; // 窗口样式
hw.lpfnWndProc = WndProc; // ??
hw.cbClsExtra = 0; // ??
hw.cbWndExtra = 0; // ??
hw.hInstance = hInstance; // ??
hw.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPLICATION)); //设定窗口图标和程序图标
hw.hCursor = LoadCursor(NULL, IDC_ARROW); //设定鼠标样式,可无视
hw.hbrBackground = (HBRUSH)BLACK_BRUSH; //背景画刷
hw.lpszMenuName = NULL; //菜单名称
hw.lpszClassName = szWindowClass; //类名
hw.hIconSm = LoadIcon(hw.hInstance, MAKEINTRESOURCE(IDI_APPLICATION)); //可无视

if (!RegisterClassEx(&hw)) // 如果注册类失败(未成功)
{
MessageBox(NULL, //第一个参数
_T("注册窗口类失败!"), // 提示框内容
_T("错误!"), // 提示框标题
NULL); // 第四个参数
return 1; // 并且返回1
}

hInst = hInstance;

HWND hWnd = CreateWindow(
szWindowClass,
szTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
480, //窗口的宽度
240, //窗口的高度
NULL,
NULL,
hInstance,
NULL
);

if (!hWnd)
{
MessageBox(NULL,
_T("创造窗口失败!"),
_T("错误!"),
NULL);

return 1;
}

// The parameters to ShowWindow explained:
// hWnd: the value returned from CreateWindow
// nCmdShow: the fourth parameter from WinMain
ShowWindow(hWnd,
nCmdShow);
UpdateWindow(hWnd);

// 主循环
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int) msg.wParam;
}
[/cpp]