Newbie question how call to win dll's

Posted By: mengnr

Newbie question how call to win dll's - 02/21/19 18:39

I want to get the current system time, however, I can't figure out the correct to call DLL routines. Advice/pointer to examples very much appreciated. I currently have this:

//#include <litec.h>
//#include <windows.h>
//long __stdcall MessageBox(HWND,char *,char *,long);
//MessageBox = DefineApi("user32!MessageBox");

typedef struct SYSTEMTIME {
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
} SYSTEMTIME;

void __stdcall GetSystemTime(long *);
GetSystemTime = DefineApi("kernal32!GetSystemTime");

void main()
{
printf("nStart");

SYSTEMTIME tm;
long *ptm = &tm;

GetSystemTime(tm);

printf("nDonenn");
}


Many thanks, Martin
Posted By: Petra

Re: Newbie question how call to win dll's - 02/21/19 20:12

You must call functions like DefineAPI inside the main function, not outside.
© 2024 lite-C Forums