TDM-GCC编译win32程序

来源:互联网 发布:赛奇排名优化查询工具 编辑:程序博客网 时间:2024/06/08 12:03
#include<windows.h>//#pragma comment(lib,"user32.lib")//#pragma comment(lib,"gdi32.lib")int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd){HDC hdc;HWND hwnd;COLORREF clr;TCHAR szBuffer[] = TEXT("您好呀,欢迎来到英雄联盟!");hwnd = GetDesktopWindow();hdc = GetWindowDC(hwnd);SetBkMode(hdc,TRANSPARENT);clr = SetTextColor(hdc,RGB(0,255,0));TextOut(hdc,0,0,szBuffer,lstrlen(szBuffer));SetTextColor(hdc,RGB(255,0,0));TextOut(hdc,0,20,szBuffer,lstrlen(szBuffer));SetBkMode(hdc,OPAQUE);SetTextColor(hdc,RGB(0,0,255));TextOut(hdc,0,40,szBuffer,lstrlen(szBuffer));SetTextColor(hdc,clr);ReleaseDC(hwnd,hdc);Sleep(5000);return 0;}

编译的时候一定要加“-mwindows”,否则编译出错:

C:\Users\jackz\AppData\Local\Temp\ccGCPuC0.o:windows7.cpp:(.text+0x5e): undefined reference to `SetBkMode@8'C:\Users\jackz\AppData\Local\Temp\ccGCPuC0.o:windows7.cpp:(.text+0x74): undefined reference to `SetTextColor@8'C:\Users\jackz\AppData\Local\Temp\ccGCPuC0.o:windows7.cpp:(.text+0xae): undefined reference to `TextOutA@20'C:\Users\jackz\AppData\Local\Temp\ccGCPuC0.o:windows7.cpp:(.text+0xc4): undefined reference to `SetTextColor@8'C:\Users\jackz\AppData\Local\Temp\ccGCPuC0.o:windows7.cpp:(.text+0xfb): undefined reference to `TextOutA@20'C:\Users\jackz\AppData\Local\Temp\ccGCPuC0.o:windows7.cpp:(.text+0x111): undefined reference to `SetBkMode@8'C:\Users\jackz\AppData\Local\Temp\ccGCPuC0.o:windows7.cpp:(.text+0x127): undefined reference to `SetTextColor@8'C:\Users\jackz\AppData\Local\Temp\ccGCPuC0.o:windows7.cpp:(.text+0x15e): undefined reference to `TextOutA@20'C:\Users\jackz\AppData\Local\Temp\ccGCPuC0.o:windows7.cpp:(.text+0x173): undefined reference to `SetTextColor@8'collect2.exe: error: ld returned 1 exit status


0 0
原创粉丝点击