-
Using timeGetTime()
i get a strange error, and i don't really understand why.
Heres my code:
Code:
// test2.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
HINSTANCE hInst;
LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM);
char szProgName[] = "Text Altering Program"; /* name of application */
int WINAPI WinMain( HINSTANCE hInst, /*Win32 entry-point routine */
HINSTANCE hPreInst,
LPSTR lpszCmdLine,
int nCmdShow )
{
HWND hWnd;
MSG lpMsg;
WNDCLASS wc;
if( !hPreInst ) /*set up window class and register it */
{
wc.lpszClassName = szProgName;
wc.hInstance = hInst;
wc.lpfnWndProc = WndProc;
wc.hCursor = LoadCursor( NULL, IDC_ARROW );
wc.hIcon = LoadIcon( NULL, IDI_APPLICATION );
wc.lpszMenuName = "Menu";
wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
wc.style = 0;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
if( !RegisterClass( &wc ) )
return FALSE;
}
hWnd = CreateWindow( szProgName, /* now create the window */
"Text Altering Program",
WS_OVERLAPPEDWINDOW, //|WS_SYSMENU|WS_MINIMIZEBOX,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
(HWND)NULL,
(HMENU)NULL,
(HINSTANCE)hInst,
(LPSTR)NULL );
ShowWindow(hWnd, nCmdShow );
UpdateWindow( hWnd );
while( GetMessage( &lpMsg, NULL, 0, 0 ) ) /* begin the message loop */
{
TranslateMessage( &lpMsg );
DispatchMessage( &lpMsg );
}
return( lpMsg.wParam);
}
LRESULT CALLBACK WndProc( HWND hWnd, UINT messg, /*callback procedure */
WPARAM wParam, LPARAM lParam )
{
float time = timeGetTime();
char array[2];
switch(messg)
{
case WM_CREATE:
itoa(time, array, 1);
MessageBox(hWnd, array, NULL, NULL);
case WM_DESTROY:
PostQuitMessage( 0 );
break;
default:
return( DefWindowProc( hWnd, messg, wParam, lParam ) );
}
return( 0L );
}
the error i get is:
test2.obj : error LNK2001: unresolved external symbol __imp__timeGetTime@0
Why am i getting that error? (I have included <mmsystem.h> in stdafx.h)
-
You need to link winmm.lib.
-