Bonjour a tous,
voici ma question: Je desirerai appeler une API windows dans un bloc de code ASM compilé avec VC++
Voila le code qui me pose probleme: l'exemple 1 compile et s'execute sans erreur, l'exemple 2 compile et genere une erreur au moment du 'call MessageBox' car ici l'API est appelee directement.
//EX1: The good one
#include <windows.h>
#include <stdio.h>
//Prevent the console from popping up during the program
#pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" )
char MsgBoxText[] = "MsgBoxText";
char MsgBoxCaption[] = "MsgBoxCaption";
void MyMessageBox(int a, int b, int c, int d)
{
MessageBox((HWND)a, (LPCTSTR)b, (LPCTSTR)c, (UINT)d);
}
void main(void)
{
int addTxt = (int)MsgBoxText;
int addCap = (int)MsgBoxCaption;
__asm
{
push MB_OK
push addTxt
push addCap
push NULL
call MyMessageBox
add esp,0x10
}
}
/////////////////////////////////////////////////////////////////////////////////
//EX2: The bad one
#include <windows.h>
#include <stdio.h>
//Prevent the console from popping up during the program
#pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" )
char MsgBoxText[] = "MsgBoxText";
char MsgBoxCaption[] = "MsgBoxCaption";
void main(void)
{
int addTxt = (int)MsgBoxText;
int addCap = (int)MsgBoxCaption;
__asm
{
push MB_OK
push addTxt
push addCap
push NULL
call MessageBox
add esp,0x10
}
}
Merci d'avance