APPX is the Premier Development and Runtime Environment for Business Application Software
(Answer) (Category) FAQ's - APPX Software, Inc. : (Category) APPX Utility : (Category) APPX Development Environment : (Category) Tips & Techniques :
When I execute SLEEP command from an Appx CALL i get the error 'You've CALL'ed C:\WINDOWS\SYSTEM32\kernel32.dll,Sleep with the wrong calling convention'
You need to add a '@' to the end of the subroutine name:

C:\WINDOWS\SYSTEM32\kernel32.dll,Sleep@

That tells Appx to call the Sleep subroutine with the correct calling convention (for some reason, Windows supports a number of different "calling conventions", or rules for calling a function, and most of the kernel32 routines use a non-standard convention - there's no way for Appx to know which convention to use so you have to tell us).

Windows supports two different (and incompatible) "calling conventions" - __stdcall and __cdecl. By default, most applications (including Appx) use the __cdecl calling convention. When you invoke a function that uses the __cdecl calling convention, the caller (that's Appx) pops arguments off the top of the runtime stack when the function ends. When you invoke a function that uses the __stdcall convention, that function cleans its own arguments off of the top of the runtime stack before it returns to the caller. Appx can't tell the difference between __cdecl and __stdcall functions. Appx assumes (unless you tell it otherwise) that you want to call __cdecl functions. If you invoke a __stdcall function (and you don't tell Appx that you're calling a __stdcall function), the runtime stack will be corrupted.
APPX tries to recover from this error but will also display a CASSERT message that tells you that you've CALL'ed a function with the wrong convention (the message includes the name of the function that you've called). If you see that message, add a '@' to the end of the function name (or, if you already have a '@' at the end of the function name, remove it). The '@' is the "windows way" to tell Appx to use the __stdcall convention to call your function. For example, you currently invoke the Kernel32,DeleteFileA - change that to Kernel32,DeleteFile@.
So how can you tell which functions are __stdcall and which functions are __cdecl? That's not an easy question to answer - that information is included with the Microsoft C compiler, but I don't see it anywhere else. That's why I'm displaying the CASSERT message here; so you'll know when you run into a problem. In general, most of the functions that you find in Kernel32.dll will be __stdcall functions (so you need to add an @ to the end of each Kernel32.dll function name).
P.S. If you want to learn more about calling conventions: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/_core_Calling_Conventions_Topics.asp

[Append to This Answer]
2006-Jan-03 12:00pm
Previous: (Answer) I am using a --- STREAM WRITE call on a file that is > 2GB. It doesn't crash or return an error code, but it doesn't write to a file either
Next: (Answer) How can i set default values during data entry and make Appx remember them from one entry to the next one?
This document is: http://board.appx.com/cgi-bin/fom.cgi?file=592
[Search] [Appearance]
This is a Faq-O-Matic 2.719.
Copyright 2003 by APPX Software, Inc. All rights reserved.