kode yard
all about C++ and PHP
Thursday, November 5, 2009
clipboard logger
This code snippet logs all clipboard text in a log file...
#include
#include
#include
#include
using namespace std;
void myfree();
FILE *fp;
char *p;
HANDLE clip;
int main()
{
HANDLE clip;
p=(char*)malloc(1);
*p='\0';
fp= fopen("log.txt", "a");
atexit(myfree);
while(true)
{
if (OpenClipboard(NULL))
{
clip = GetClipboardData(CF_TEXT);
if(strcmp(p,(char*)clip)!=0)
{
free(p);
p = (char*)malloc(strlen((char*)clip)+1);
strcpy(p,(char*)clip);
fprintf(fp,"%s",p);
}
CloseClipboard();
}
Sleep(500);
}
}
void myfree()
{
free(p);
if(fp!=NULL)
fclose(fp);
free(clip);
}
This is well tested in Dev C++.
Newer Posts
Older Posts
Home
Subscribe to:
Posts (Atom)