typedef int (WINAPI *MESSAGEBOXTIMEOUT)(HWND hWnd, LPSTR lpText,
LPSTR lpCaption, UINT uType, WORD wLanguageId, DWORD dwMilliseconds);
MESSAGEBOXTIMEOUT MessageBoxTimeOut;
//---------------------------------------------------------------------------
int CrnMsgBoxTimeOut(HWND hWnd, LPSTR lpText, LPSTR lpCaption, UINT uType, DWORD dwMilli)
{
int nRet = -1;
HINSTANCE hDll = LoadLibrary("User32.dll");
if (hDll)
{
MessageBoxTimeOut = (MESSAGEBOXTIMEOUT)
::GetProcAddress(hDll, "MessageBoxTimeoutA");
if (MessageBoxTimeOut)
{
nRet = MessageBoxTimeOut(hWnd, lpText, lpCaption, uType, 0, dwMilli);
}
}
::FreeLibrary(hDll);
return nRet;
}
// 调用举例:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
CrnMsgBoxTimeOut(0, TEXT("消息内容"), TEXT("标题"),
MB_OK | MB_ICONINFORMATION, 10000);
}