Hello, I am trying to create a program to read text from clipboard. It works great, but when I copy a file the program crashes. I am trying to make it to ignore any files and only output text. My code so far is the following:
#include "stdafx.h"
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
while(true)
{
Sleep(100);
OpenClipboard(NULL);
HANDLE foo = GetClipboardData(CF_TEXT);
CloseClipboard();
LPVOID lptstr = GlobalLock(foo);
cout << (char *)lptstr;
}
return 0;
}
P.S. Sorry for my bad english...