纯c语言 MessageBoxTimeout 问题??

wzxiaodu 2019-08-24 04:27:11

#include <windows.h>

//extern "C"
//{
int WINAPI MessageBoxTimeoutA(IN HWND hWnd, IN LPCSTR lpText, IN LPCSTR lpCaption, IN UINT uType, IN WORD wLanguageId, IN DWORD dwMilliseconds);
int WINAPI MessageBoxTimeoutW(IN HWND hWnd, IN LPCWSTR lpText, IN LPCWSTR lpCaption, IN UINT uType, IN WORD wLanguageId, IN DWORD dwMilliseconds);
//};
#ifdef UNICODE
#define MessageBoxTimeout MessageBoxTimeoutW
#else
#define MessageBoxTimeout MessageBoxTimeoutA
#endif


int main()
{
MessageBoxTimeout(0,"ttttt","111111",0,0,2000);
return 0;
}



错误如下:
c:(.text+0x699): undefined reference to `MessageBoxTimeoutA@24'


怎么解决???
...全文
261 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
wzxiaodu 2019-08-24
  • 打赏
  • 举报
回复
加上#pragma也是不行的,gcc不认啊!
Intel0011 2019-08-24
  • 打赏
  • 举报
回复
3楼正解,MessageBoxTimeoutA和MessageBoxTimeoutW是在user32中导出的

#include <windows.h>

int WINAPI MessageBoxTimeoutA(IN HWND hWnd, IN LPCSTR lpText, IN LPCSTR lpCaption, IN UINT uType, IN WORD wLanguageId, IN DWORD dwMilliseconds);
int WINAPI MessageBoxTimeoutW(IN HWND hWnd, IN LPCWSTR lpText, IN LPCWSTR lpCaption, IN UINT uType, IN WORD wLanguageId, IN DWORD dwMilliseconds);

#ifdef UNICODE
#define MessageBoxTimeout MessageBoxTimeoutW
#else
#define MessageBoxTimeout MessageBoxTimeoutA
#endif 
 
#pragma comment(lib, "user32")

int main(void)
{
   MessageBoxTimeout(0,"ttttt","111111",0,0,2000);
   return 0;
}
  • 打赏
  • 举报
回复
#include <windows.h>

#pragma comment(lib, "user32.lib")
wzxiaodu 2019-08-24
  • 打赏
  • 举报
回复
VB6 里

Private Declare Function MessageBoxTimeout Lib "user32" Alias "MessageBoxTimeoutA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long, ByVal wlange As Long, ByVal dwTimeout As Long) As Long

这个没问题!!!!!
wzxiaodu 2019-08-24
  • 打赏
  • 举报
回复
是缺什么连接库吗?
我用下面编译也是这种错误??

gcc 1111.c -luser32 -o 1111.exe

69,369

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧