X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f NNTP-Posting-Date: Sat, 14 Mar 2009 17:15:55 -0500 From: NoEmailAds AT execpc DOT com (Chris Giese) Newsgroups: comp.os.msdos.djgpp Subject: Re: Copying clipboard into string Date: Sat, 14 Mar 2009 23:14:24 GMT Organization: PROPULSION GROUP Message-ID: <49bc3a01.31249272@news.execpc.com> References: <49bad553$1$1110$4fafbaef AT reader4 DOT news DOT tin DOT it> X-Newsreader: Forte Free Agent 1.21/32.243 Lines: 99 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 69.95.232.77 X-Trace: sv3-TOrs9Q9eUpfj6XXbVW/2k64coSyP4WXccmrVM7+TrP+kDFuKqMhoOyEmVh0ZdahNgznPao+6wLpf/i5!Nmx8uPwe5Tv4MYZssP56TM3BbNWO6UXdurpPgYDFlG4ZA93od2RAtv70c2ddvndDnfxbUtezTfMe!gNOHx+tTAkRe X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.39 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Eli Zaretskii wrote: >> From: "Jason" >> Date: Fri, 13 Mar 2009 22:51:10 +0100 >> >> it possible with Djgpp copying the contents of Windows >> clipboard into a string. > >Yes, assuming you are on Windows 9X/Me. On W2K and later, no (AFAIK). > >> What commands should use? > >If you mean programmatically, then you will need to write code that >accesses the Windows clipboard through Int 2Fh/AH=17h. > >> Do you have examples of code? #include #include #include #include static int rm_int_es_bx(void *buf, unsigned buf_size, __dpmi_regs *regs, unsigned int_num) { int seg, sel; /* allocate conventional memory */ seg = __dpmi_allocate_dos_memory((buf_size + 15) / 16, &sel); if(seg == -1) { printf("Error: can't allocate conventional memory\n"); return -1; } /* copy buffer to conventional memory */ dosmemput(buf, buf_size, seg * 16); /* point real-mode ES and BX to buffer and do interrupt */ regs->x.es = seg; regs->x.bx = 0; __dpmi_int(int_num, regs); /* copy conventional memory back to buffer and free conventional memory */ dosmemget(seg * 16, buf_size, buf); __dpmi_free_dos_memory(sel); return 0; } int main(void) { static const char to[] = "Hello"; unsigned long len; __dpmi_regs regs; char *from; /* identify WINOLDAP version */ regs.x.ax = 0x1700; __dpmi_int(0x2F, ®s); if(regs.x.ax == 0x1700) { printf("Can't access Windows clipboard\n"); return 1; } /* open clipboard (ignore return value) */ regs.x.ax = 0x1701; __dpmi_int(0x2F, ®s); /* check if any text already in clipboard */ regs.x.ax = 0x1704; regs.x.dx = 0x01; __dpmi_int(0x2F, ®s); len = regs.x.dx * 0x10000L + regs.x.ax; if(len == 0) printf("No text in Windows clipboard\n"); else { from = malloc(len); if(from == NULL) printf("Not enough memory to read Windows clipboard\n"); else { regs.x.ax = 0x1705; regs.x.dx = 0x01; rm_int_es_bx(from, len, ®s, 0x2F); if(regs.x.ax == 0) printf("Error reading Windows clipboard\n"); else printf("Text in Windows clipboard is:\n%s\n", from); free(from); } } /* set clipboard data */ printf("Writing to Windows clipboard...\n"); regs.x.ax = 0x1703; /* 1=text, 2=bitmap, 3=.WMF...see Ralf Brown's list for more: */ regs.x.dx = 0x01; regs.x.si = 0; regs.x.cx = sizeof(to); rm_int_es_bx(to, sizeof(to), ®s, 0x2F); if(regs.x.ax == 0) printf("Error writing Windows clipboard\n"); /* close clipboard */ regs.x.ax = 0x1708; __dpmi_int(0x2F, ®s); return 0; }