2014-03-01 181 views
0

我想在C++中捕獲剪貼板拷貝&剪切地址,但編譯器說有GetClipboardSequenceNumber()函數沒有聲明的錯誤。我如何能夠聲明這一點。GetClipboardSequenceNumber()函數聲明

#include "stdafx.h" 
#include <iostream> 
#include <windows.h> 
#include <conio.h> 
#include <winuser.h> 
using namespace std; 

int _tmain(int argc, _TCHAR* argv[]) 
{ 
    DWORD y = GetClipboardSequenceNumber(); 
    while(1) { 
     Sleep(1000); 
     if(y!=GetClipboardSequenceNumber()) 
      { 
       OpenClipboard(NULL); 
       HANDLE X =GetClipboardData(CF_TEXT); 
       cout<<(char*)GlobalLock(X); 
       GlobalUnlock(X); 
      } 
      } 
getch(); 
return 0; 
} 
+0

你似乎在使用特定於操作系統的API調用(我猜Windows)。請適當修改你的標籤。請同時縮進您的代碼。 – abligh

+0

是的,我正在使用Windows 7.你能給我正確的代碼 – user3314731

+0

不,但其他人可能能夠,如果你在你的帖子上設置適當的標籤。 – abligh

回答

0

這可能取決於編譯器,但documentation狀態,這是僅適用於Windows 2000和更新,所以你應該確保你聲明的正確WINVER版本來訪問所需的功能。即:在包含Windows.h之前#define WINVER 0x0501獲取它包含爲XP定義的函數,但不包含僅在Windows Vista中可用的函數(0x600)。如果您使用Visual C++,那麼Platform SDK傾向於定義一個合理的值。但要確定 - 在包含任何Windows頭文件之前,同時定義WINVER和_WIN32_WINNT。

+0

我的編譯器是Dev C++,我的os是win 7 32位。你說的工作不起作用。請告訴我我該怎麼做 – user3314731