Witam,
zainstalowałem sobie przed kilkoma dniami Visual'a C++ 6.0 (miałem reinstalkę systemu). Postanowiłem, w celu odswieżenie sobie wiadomości, napisać prosty programik w WinAPI. Tu pojawił się problem. Kompilator pokazuję, że kod nie ma błędów. Kod :
#include <windows.h>
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM) ;
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow)
{
static char nazwaProgramu[] = "Hello" ;
HWND hwnd = NULL ;
MSG msg ;
WNDCLASS klasaOkna ;
klasaOkna.style = CS_HREDRAW | CS_VREDRAW ;
klasaOkna.lpfnWndProc = WndProc ;
klasaOkna.cbWndExtra = 0 ;
klasaOkna.cbClsExtra = 0 ;
klasaOkna.hInstance = hInstance ;
klasaOkna.hIcon = LoadIcon(NULL, IDI_APPLICATION) ;
klasaOkna.hCursor = LoadCursor(NULL, IDC_ARROW) ;
klasaOkna.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH) ;
klasaOkna.lpszMenuName = NULL ;
klasaOkna.lpszClassName = nazwaProgramu ;
if(!RegisterClass(&klasaOkna) )
{
MessageBox(hwnd, "Wystapil blad podczas uruchamiania programu", nazwaProgramu, MB_ICONERROR) ;
return 0 ;
}
hwnd = CreateWindow(nazwaProgramu,
"Pierwszy program w WinAPI",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL ) ;
ShowWindow(hwnd, iCmdShow) ;
UpdateWindow(hwnd) ;
while(GetMessage(&msg, NULL, 0, 0) )
{
TranslateMessage(&msg) ;
DispatchMessage(&msg) ;
}
return msg.wParam ;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static int cxChar, cxCaps, cyChar ;
HDC hdc ;
PAINTSTRUCT ps ;
TEXTMETRIC tm ;
switch(message)
{
case WM_CREATE :
hdc = GetDC(hwnd) ;
GetTextMetrics(hdc, &tm) ;
cxChar = tm.tmAveCharWidth ;
cxCaps = cxChar + (cxChar / 2) ;
cyChar = tm.tmHeight + tm.tmExternalLeading ;
ReleaseDC(hwnd, hdc) ;
return 0;
case WM_PAINT :
hdc = BeginPaint(hwnd, &ps) ;
EndPaint(hwnd, &ps) ;
return 0 ;
case WM_DESTROY :
PostQuitMessage(0) ;
return 0 ;
}
return DefWindowProc(hwnd, message, wParam, lParam) ;
}
Jednak, gdy próbuje program zlinkować otrymuję komunikaty
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/pierwszy.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe
Co robić ? Co jest nie tak z tym programikiem ?