Hi,

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?
Thanks.
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?

Regards,
Mariano.

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

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

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getlocaltime.asp
Posted on 2004-04-13 05:16:15 by Vortex
First of all thanks for your attention. I enclose my code.

Regards,
oleg
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.

func.asm:

.model flat,stdcall
include windows.inc

main.cpp:

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

I've attached the new files anyway :)

Regards,
Mariano.

:alright:
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

...
ret

Thanks once again. I enclose a working code.

Regards,
Oleg
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.

Regards,
Mariano.



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