どうもうまくいきません。
どうすれば良いんですか?
#include <windows.h>
static TCHAR AppName[274];
HANDLE hFile;
DWORD dwBytes;
BITMAPFILEHEADER bmpFileHeader;
BITMAPINFO bmpInfo;
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{
static strPath[MAX_PATH];
HDC hdc, hBuffer;
PAINTSTRUCT ps;
LPCREATESTRUCT lpcsWnd;
static HBITMAP hBitmap;
int iScan = 1;
static BYTE * bPixelBits;
const int WIDTH = 4 * ((bmpInfo.bmiHeader.biWidth * bmpInfo.bmiHeader.biBitCount + 31)/ 32);
switch (msg)
{
case WM_DESTROY:
CloseHandle(hFile);
free(bPixelBits);
PostQuitMessage(0);
return 0;
case WM_CREATE:
bPixelBits = (BYTE *) malloc (WIDTH);
CreateCompatibleDC(hdc);
hBitmap = LoadBitmap(((LPCREATESTRUCT)lp)->hInstance, TEXT("Launcher"));
GetCurrentDirectory(MAX_PATH, strPath);
wsprintf(strPath, TEXT("%s\\%s"), strPath, TEXT("Game.ini"));
GetPrivateProfileString(TEXT("Game"), TEXT("Title"), TEXT("Game"), AppName, 274, strPath);
wsprintf(AppName, TEXT("%s Launcher"), AppName);
return 0;
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
for(; iScan <= bmpInfo.bmiHeader.biHeight; iScan++)
{
ReadFile(hFile, bPixelBits, WIDTH, &dwBytes, NULL);
SetDIBitsToDevice(hdc, 0, 0, bmpInfo.bmiHeader.biWidth, bmpInfo.bmiHeader.biHeight, 0, 0, iScan, 1, bPixelBits, &bmpInfo, DIB_RGB_COLORS);
}
SetFilePointer(hFile, sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER), NULL, FILE_BEGIN);
return 0;
}
return DefWindowProc(hwnd, msg, wp, lp);
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
HWND hwnd;
MSG msg;
WNDCLASS winc;
hFile = CreateFile("Launcher.bmp", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE) return 1;
ReadFile(hFile, &bmpFileHeader, sizeof(BITMAPFILEHEADER), &dwBytes, NULL);
if (bmpFileHeader.bfType != 0x4D42) {
MessageBox(NULL, TEXT("This is not a bitmap file"), NULL, MB_OK);
return 1;
}
ReadFile(hFile, &bmpInfo, sizeof (BITMAPINFOHEADER), &dwBytes, NULL);
winc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
winc.lpfnWndProc = WndProc;
winc.cbClsExtra = winc.cbWndExtra = 0;
winc.hInstance = hInstance;
winc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
winc.hCursor = LoadCursor(NULL, IDC_ARROW);
winc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
winc.lpszMenuName = NULL;
winc.lpszClassName = TEXT("MAIN");
if(!RegisterClass(&winc)) return 0;
hwnd = CreateWindow(TEXT("MAIN"), TEXT(""), WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_VISIBLE, (GetSystemMetrics(SM_CXSCREEN) - (GetSystemMetrics(SM_CXFIXEDFRAME) + GetSystemMetrics(SM_CXEDGE) + 640)) / 2, (GetSystemMetrics(SM_CYSCREEN) - (GetSystemMetrics(SM_CYFIXEDFRAME) + GetSystemMetrics(SM_CYEDGE) + 480)) / 2, GetSystemMetrics(SM_CXFIXEDFRAME) + GetSystemMetrics(SM_CXEDGE) + 640, GetSystemMetrics(SM_CYFIXEDFRAME) + GetSystemMetrics(SM_CYEDGE) + 480, NULL, NULL, hInstance, NULL);
SetWindowText(hwnd, AppName);
if (hwnd == NULL) return 0;
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}