Hi Guys,
Forgive me if I'm repeating something which has already been covered (I've looked everywhere I can think of regarding this topic but without much luck so far).
Basically, I'm trying to register some global functions which use the __stdcall calling convention (some Win32 API calls).
I haven't yet managed however to find a combination of calling convention flags which prevent the occurance of an exception when making those calls.
Below is the code I am using in my 'MessageBoxA' test call. As it is, the message box comes up fine, but crashes on return which is what leads me to believe it's the calling convention difference between __stdcall and __cdecl.
// C++
// Register win32 API calls.
m_pEngine->RegisterGlobalFunction( "int MessageBox( uint, string, string, bits )", asFUNCTION(MessageBoxA), asCALL_CDECL );
// Define all constants
strConstants[0] = '\0';
sprintf( &strConstants[strlen(strConstants)], "const bits MB_OK = 0x%x;\n", MB_OK );
sprintf( &strConstants[strlen(strConstants)], "const bits MB_ICONINFORMATION = 0x%x;\n", MB_ICONINFORMATION );
// Add constants to the engine
m_pEngine->AddScriptSection( "core", "Constants", strConstants, strlen(strConstants) );
(Note: 'string' is analogous to 'bstr' in my test engine).
//Script
bool Main()
{
MessageBox( 0, "The script is starting up, just so you know! :)", "Initializing", MB_OK | MB_ICONINFORMATION );
return true;
}
Can anyone help me out with this? If I have to write wrapper functions for all of the Win32 API calls which I would like to expose then that's not a terrible deal, but I would just like to make sure I'm not doing anything stupid before I go down that route.
Thanks in advance!
Adam
[Edited by - daedalusd on June 30, 2004 9:26:17 PM]