Thread: Using timeGetTime()

  1. #1
    The Earth is not flat. Clyde's Avatar
    Join Date
    Mar 2002
    Posts
    1,403

    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)
    Last edited by Clyde; 05-28-2002 at 02:36 PM.

  2. #2
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    You need to link winmm.lib.

  3. #3
    The Earth is not flat. Clyde's Avatar
    Join Date
    Mar 2002
    Posts
    1,403
    aha, thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Having only one function run at higher priority
    By ulillillia in forum C Programming
    Replies: 35
    Last Post: 02-24-2008, 06:56 PM
  2. RTS: wargame
    By DavidP in forum Game Programming
    Replies: 12
    Last Post: 01-01-2007, 04:32 PM
  3. Problem with timeGetTime()
    By Bill83 in forum Windows Programming
    Replies: 1
    Last Post: 01-15-2006, 12:28 AM
  4. timeGetTime(), getSystemTime(), GetTickCount()
    By Shadow12345 in forum Windows Programming
    Replies: 1
    Last Post: 11-02-2002, 10:35 AM
  5. timeGetTime() on mac
    By btq in forum C++ Programming
    Replies: 0
    Last Post: 06-04-2002, 04:32 PM