简体   繁体   English

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

[英]What do I need to include to use OpenClipboard()?

I wrote a short program do test out the OpenClipboard function. 我写了一个简短的程序来测试OpenClipboard功能。 I copied from here and it doesn't look like you need to include anything. 我是从这里复制的,看起来您不需要包含任何内容。 I am programming with notepad and command prompt, so I don't have a third party program telling me what's wrong. 我正在使用记事本和命令提示符进行编程,因此没有第三方程序告诉我出了什么问题。 The error messages are simply that all the stuff used in the code snippet isn't declared in this scope: 错误消息只是因为未在此范围内声明代码片段中使用的所有内容:

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);
               ^

The OpenClipboard documentation explains that the header file to use is OpenClipboard文档说明了要使用的头文件是

Winuser.h (include Windows.h) Winuser.h(包括Windows.h)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM