I write a program in VC++ which calls a function written in assembly. The function gets four integer parameters, namely wHour, wMinute, wSecond, and wMilliseconds and returns time in milliseconds. Its works perfectly. Now I'm trying to get the local time within my assembly function
INVOKE GetLocalTime, ADDR sysTime
and have no errors during assembling but when I build my programe in VC++ I get the error: func.obj : error LNK2001: unresolved external symbol _GetLocalTime

What do I wrong?
Posted on 2004-04-13 04:46:12 by oleg
I don't know why but you are trying to link the function GetLocalTime as a C one when it's a stdcall one...

Could you post your code?


Posted on 2004-04-13 05:04:15 by Eternal Idol Birmingham

Just as Eternal Idol Birmingham said, GetLocalTime is a stdcall function. For more information, have a look at:

Posted on 2004-04-13 05:16:15 by Vortex
First of all thanks for your attention. I enclose my code.

Posted on 2004-04-13 09:45:02 by oleg
Done, I've fixed it but with windows.inc and not that Irvine2.inc that I don't have. I've tested it and it works.

The problem is the parameter convention, you have declared C in the asm source code which is fine to link to the main.cpp but I will not link to the API. So I've changed that to stdcall and replaced your old C calling of mytime to a stdcall one and now it works.


.model flat,stdcall
include windows.inc


extern "C" int __stdcall mytime(int,int,int,int);

I've attached the new files anyway :)


Posted on 2004-04-13 09:55:45 by Eternal Idol Birmingham
Thank you very much, Mariano. You helped me a lot. Nevetheless, I made a small fix also.
Instruction in func.asm
ret 0

gave a severe error during building. It should be just


Thanks once again. I enclose a working code.

Posted on 2004-04-13 13:27:05 by oleg
Yes, of course because there isn't any real address in the stack, anyway that isn't a code of my own, its your very first code ;)

It was working fine on my machine so I didn't see the rest of the code.


Posted on 2004-04-13 14:10:44 by Eternal Idol Birmingham