I have a project that needs to be linked to Kernel32.dll. For some reason, even after I link libkernel32.a in "Build Options" < "Linker" it still gives me the same errors. Here's the project code:
#include <windows.h>
#include <string>
#include "resource.h"
using namespace std;
LRESULT CALLBACK WinProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
HINSTANCE hInstance;
HWND Label1;
HANDLE Label1Handle;
int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine, int nCmdShow) {
MSG msg;
WNDCLASS wc;
HWND hwnd = NULL;
hInstance = hThisInstance;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hbrBackground = CreateSolidBrush(RGB(241, 241, 241));
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(MAIN_ICON));
wc.hInstance = hThisInstance;
wc.lpfnWndProc = WinProc;
wc.lpszClassName = "Window";
wc.lpszMenuName = NULL;
wc.style = CS_HREDRAW | CS_VREDRAW;
if (!RegisterClass(&wc)) {
MessageBox(NULL, "Error registering class", "ERROR", MB_OK);
return 0;
}
hwnd = CreateWindow("Window",
"Window",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
640,
400,
NULL,
NULL,
hThisInstance,
NULL);
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
while (GetMessage(&msg, (HWND)NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WinProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
switch (msg) {
case WM_CREATE: {
string LabelText1 = "Hello";
Label1 = CreateWindowEx(0,
"STATIC",
"Some static text",
WS_CHILD | WS_VISIBLE,
25,
125,
150,
20,
hwnd,
(HMENU)static_1,
hInstance,
0);
SendDlgItemMessage(hwnd, static_1, WM_SETFONT, (WPARAM)CreateFont(12, 10, 0, 0, 500, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 0, TEXT("Terminal")), MAKELPARAM(TRUE, 0));
} break;
case WM_DESTROY: {
PostQuitMessage(0);
return 0;
} break;
case WM_CLOSE: {
DestroyWindow(hwnd);
} break;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}