Let the compiler help you. Use PChar
, is the safest and easiest way to do it.
int WINAPI MessageBox(
_In_opt_ HWND hWnd,
_In_opt_ LPCTSTR lpText,
_In_opt_ LPCTSTR lpCaption,
_In_ UINT uType
);
MessageBox(0, PChar('Teste'), PChar('Titulo'), MB_OK);
However, in most cases I would use:
First of all:
uses Dialogs;
ShowMessage(const Msg: String);
Second Place
uses Forms;
Application.MessageBox(Text, Caption: PChar; Flags: LongInt = MB_OK);
If you migrate your application to Unicode
, you will not want to call the MessageBoxA
function, because if your string is unicode (it probably will be if you declare your variable as string
), your code may fail .