0
我写了一个简短的程序做测试了OpenClipboard
函数。我从here复制,它看起来不需要包含任何东西。我用记事本和命令提示编程,所以我没有第三方程序告诉我什么是错的。该错误消息仅仅是在代码片段中使用的所有的东西并不在此范围中声明:我需要包含什么来使用OpenClipboard()?
programm1.cpp: In function 'void toClipboard(const string&)': programm1.cpp:65:17: error: 'OpenClipboard' was not declared in this scope OpenClipboard(0); ^ programm1.cpp:66:17: error: 'EmptyClipboard' was not declared in this scope EmptyClipboard(); ^ programm1.cpp:67:2: error: 'HGLOBAL' was not declared in this scope HGLOBAL hg=GlobalAlloc(GMEM_MOVEABLE,s.size()); ^ programm1.cpp:67:10: error: expected ';' before 'hg' HGLOBAL hg=GlobalAlloc(GMEM_MOVEABLE,s.size()); ^ programm1.cpp:68:7: error: 'hg' was not declared in this scope if (!hg){ ^ programm1.cpp:69:18: error: 'CloseClipboard' was not declared in this scope CloseClipboard(); ^ programm1.cpp:72:20: error: 'hg' was not declared in this scope memcpy(GlobalLock(hg),s.c_str(),s.size()); ^ programm1.cpp:72:22: error: 'GlobalLock' was not declared in this scope memcpy(GlobalLock(hg),s.c_str(),s.size()); ^ programm1.cpp:72:42: error: 'memcpy' was not declared in this scope memcpy(GlobalLock(hg),s.c_str(),s.size()); ^ programm1.cpp:73:17: error: 'GlobalUnlock' was not declared in this scope GlobalUnlock(hg); ^ programm1.cpp:74:19: error: 'CF_TEXT' was not declared in this scope SetClipboardData(CF_TEXT,hg); ^ programm1.cpp:74:29: error: 'SetClipboardData' was not declared in this scope SetClipboardData(CF_TEXT,hg); ^ programm1.cpp:75:17: error: 'CloseClipboard' was not declared in this scope CloseClipboard(); ^ programm1.cpp:76:15: error: 'GlobalFree' was not declared in this scope GlobalFree(hg); ^
'#include';您还需要链接到'user32.lib'和'kernel32.lib',如所使用函数的文档中所述(在底部)。 –
@MatteoItalia谢谢^^那是我正在寻找的mssing行 – PlatinTato