From: asit on 4 Nov 2009 13:55 Here is a code I wrote to log all clipboard text in the log file. #include <windows.h> #include <iostream> #include <stdio.h> #include <string.h> #include <stdlib.h> 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); if (OpenClipboard(NULL)) while(true) { 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); } Sleep(500); } } void myfree() { free(p); if(fp!=NULL) fclose(fp); free(clip); } The code runs fine. But as the program runs, why can't I do as usual copy-paste stuff ??
From: Preben Friis on 4 Nov 2009 14:16 "asit" <lipun4u(a)gmail.com> wrote in message news:f1284106-4a97-4ecb-b071-751f97e70267(a)t18g2000vbj.googlegroups.com... > The code runs fine. But as the program runs, why can't I do as usual > copy-paste stuff ?? http://msdn.microsoft.com/en-us/library/ms649048(VS.85).aspx "The OpenClipboard function opens the clipboard for examination and prevents other applications from modifying the clipboard content. " .... so you are preventing other applications from using it. Change your code to close the clipboard again.... 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); }
From: asit on 4 Nov 2009 14:34 On Nov 5, 12:16 am, "Preben Friis" <no...(a)technologist.com> wrote: > "asit" <lipu...(a)gmail.com> wrote in message > > news:f1284106-4a97-4ecb-b071-751f97e70267(a)t18g2000vbj.googlegroups.com... > > > The code runs fine. But as the program runs, why can't I do as usual > > copy-paste stuff ?? > > http://msdn.microsoft.com/en-us/library/ms649048(VS.85).aspx > "The OpenClipboard function opens the clipboard for examination and prevents > other applications from modifying the clipboard content. " > > ... so you are preventing other applications from using it. > > Change your code to close the clipboard again.... > > 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); > } thank you buddy...it works...
|
Pages: 1 Prev: Windows 7 Test drive or emulator Next: GDI+ resize transformation question |