[英]What do I need to include to use OpenClipboard()?
我写了一个简短的程序来测试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); ^
OpenClipboard
文档说明了要使用的头文件是
Winuser.h(包括Windows.h)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.