C++ 使用OpenClipboard()需要包括哪些内容?

C++ 使用OpenClipboard()需要包括哪些内容?,c++,windows,clipboard,C++,Windows,Clipboard,我写了一个简短的程序来测试OpenClipboard函数。我从中复制,看起来你不需要包含任何内容。我用记事本和命令提示符编程,所以我没有第三方程序告诉我出了什么问题。错误消息只是代码段中使用的所有内容未在此范围内声明: programm1.cpp: In function 'void toClipboard(const string&)': programm1.cpp:65:17: error: 'OpenClipboard' was not declared in this scope O

我写了一个简短的程序来测试
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); ^ programm1.cpp:在函数“void toClipboard(const string&)”中: programm1.cpp:65:17:错误:“OpenClipboard”未在此范围内声明 OpenClipboard(0); ^ programm1.cpp:66:17:错误:“EmptyClipboard”未在此范围内声明 清空电路板(); ^ programm1.cpp:67:2:错误:“HGLOBAL”未在此作用域中声明 HGLOBAL hg=GlobalAlloc(GMEM_MOVEABLE,s.size()); ^ programm1.cpp:67:10:错误:应为“;”在“hg”之前 HGLOBAL hg=GlobalAlloc(GMEM_MOVEABLE,s.size()); ^ programm1.cpp:68:7:错误:“hg”未在此范围内声明 如果(!hg){ ^ programm1.cpp:69:18:错误:“CloseClipboard”未在此范围内声明 CloseClipboard(); ^ programm1.cpp:72:20:错误:“hg”未在此范围内声明 memcpy(GlobalLock(hg)、s.c_str()、s.size()); ^ programm1.cpp:72:22:错误:未在此作用域中声明“GlobalLock” memcpy(GlobalLock(hg)、s.c_str()、s.size()); ^ programm1.cpp:72:42:错误:“memcpy”未在此范围内声明 memcpy(GlobalLock(hg)、s.c_str()、s.size()); ^ programm1.cpp:73:17:错误:“GlobalUnlock”未在此作用域中声明 GlobalUnlock(hg); ^ programm1.cpp:74:19:错误:“CF_TEXT”未在此范围内声明 SetClipboardData(CF_TEXT,hg); ^ programm1.cpp:74:29:错误:“SetClipboardData”未在此作用域中声明 SetClipboardData(CF_TEXT,hg); ^ programm1.cpp:75:17:错误:“CloseClipboard”未在此范围内声明 CloseClipboard(); ^ programm1.cpp:76:15:错误:未在此作用域中声明“GlobalFree” 全球自由度(hg); ^ 文档说明要使用的头文件是

Winuser.h(包括Windows.h)

文档说明要使用的头文件是

Winuser.h(包括Windows.h)


#包括
;您还需要链接到
user32.lib
kernel32.lib
,如您正在使用的函数文档中所述(在底部)@MatteoItalia谢谢^^这是我正在寻找的mssing行
#include
;您还需要链接到
user32.lib
kernel32.lib
,正如您正在使用的函数文档中所指定的那样(在底部)@MatteoItalia谢谢^^这是我要找的mssing行。所以,别忘了导入库。另外,别忘了导入库。