-
Notifications
You must be signed in to change notification settings - Fork 4
/
Clipboard.xs
731 lines (675 loc) · 17.3 KB
/
Clipboard.xs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
/*
#######################################################################
#
# Win32::Clipboard - Interaction with the Windows clipboard
#
# Version: 0.58
# Created: 19 Nov 96
# Author: Aldo Calpini <dada@perl.it>
#
# Modified: 24 Jul 2004
# By: Hideyo Imazu <h@imazu.net>
#
#######################################################################
*/
/* uncomment next line for debug messages */
// #define WIN32__CLIPBOARD__DEBUG
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <string.h>
#include <wchar.h>
#include <winuser.h>
#include <shellapi.h>
#define __TEMP_WORD WORD /* perl defines a WORD, yikes! */
#ifdef __cplusplus
#include <stdlib.h>
#include <math.h>
extern "C" {
#endif
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#ifdef __cplusplus
}
#endif
#include "ppport.h"
#undef WORD
#define WORD __TEMP_WORD
// Section for the constant definitions.
#define CROAK croak
#define MAX_LENGTH 2048
#define TMPBUFSZ 1024
static HWND hwndThisViewer;
static HWND hwndNextViewer;
static HANDLE hEvt;
static HANDLE hThread;
/* DLL entry point */
BOOL WINAPI DllMain(HINSTANCE hDll, DWORD reason, LPVOID reserved) {
// BOOL ccb;
#ifdef WIN32__CLIPBOARD__DEBUG
printf("!XS(DllMain): DLL entry point called with reason: %ld\n", reason);
printf("!XS(DllMain): ClipboardViewer is: %ld\n", GetClipboardViewer());
#endif
if((reason == DLL_THREAD_ATTACH ||
reason == DLL_THREAD_DETACH) && hwndThisViewer) {
#ifdef WIN32__CLIPBOARD__DEBUG
printf("!XS(DllMain): hwndThisViewer=%ld\n", hwndThisViewer);
printf("!XS(DllMain): hwndNextViewer=%ld\n", hwndNextViewer);
printf("!XS(DllMain): ClipboardViewer is: %ld\n", GetClipboardViewer());
#endif
// Remove the window from the Clipboard viewers chain
// ccb = ChangeClipboardChain(hwndThisViewer, hwndNextViewer);
// printf("\tChangeClipboardChain(%ld,%ld).result = %d\n", hwndThisViewer, hwndNextViewer, ccb);
// Inform the next window we're closing
// SendMessage(hwndNextViewer,
// WM_CHANGECBCHAIN,
// (WPARAM) hwndThisViewer,
// (LPARAM) hwndNextViewer);
// kill the window
SendMessage(hwndThisViewer, WM_DESTROY, 0, 0);
// DestroyWindow(hwndThisViewer);
// SendMessage(hwndThisViewer, WM_QUIT, 0, 0);
#ifdef WIN32__CLIPBOARD__DEBUG
printf("!XS(DllMain): ClipboardViewer is now: %ld\n", GetClipboardViewer());
#endif
}
return TRUE;
}
/* Clipboard Viewer Window Procedure */
LRESULT CALLBACK ClipboardViewerWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
BOOL ccb;
// printf("!XS(ClipboardViewerWndProc): got uMsg=%d\n", uMsg);
switch(uMsg) {
case WM_CREATE:
#ifdef WIN32__CLIPBOARD__DEBUG
printf("!XS(ClipboardViewerWndProc): got WM_CREATE\n");
#endif
hwndNextViewer = SetClipboardViewer(hwnd);
#ifdef WIN32__CLIPBOARD__DEBUG
printf("!XS(ClipboardViewerWndProc): hwndNextViewer=%ld\n", hwndNextViewer);
printf("!XS(ClipboardViewerWndProc): ClipboardViewer is now: %ld\n", GetClipboardViewer());
#endif
break;
case WM_DRAWCLIPBOARD:
#ifdef WIN32__CLIPBOARD__DEBUG
printf("!XS(ClipboardViewerWndProc): got WM_DRAWCLIPBOARD (my hwnd is %ld)\n", hwnd);
#endif
// pass the message to the next viewer
SendMessage(hwndNextViewer, uMsg, wParam, lParam);
// stop waiting
SetEvent(hEvt);
break;
case WM_CHANGECBCHAIN:
#ifdef WIN32__CLIPBOARD__DEBUG
printf("!XS(ClipboardViewerWndProc): got WM_CHANGECBCHAIN\n");
#endif
// If the next window is closing, repair the chain.
if ((HWND) wParam == hwndNextViewer)
hwndNextViewer = (HWND) lParam;
// Otherwise, pass the message to the next link.
else if (hwndNextViewer != NULL)
SendMessage(hwndNextViewer, uMsg, wParam, lParam);
#ifdef WIN32__CLIPBOARD__DEBUG
printf("!XS(ClipboardViewerWndProc): ClipboardViewer is now: %ld\n", GetClipboardViewer());
#endif
break;
case WM_DESTROY:
#ifdef WIN32__CLIPBOARD__DEBUG
printf("!XS(ClipboardViewerWndProc): got WM_DESTROY\n");
printf("!XS(ClipboardViewerWndProc): ClipboardViewer is: %ld\n", GetClipboardViewer());
#endif
ccb = ChangeClipboardChain(hwnd, hwndNextViewer);
#ifdef WIN32__CLIPBOARD__DEBUG
printf("!XS(ClipboardViewerWndProc): ChangeClipboardChain(%ld,%ld).result = %d\n", hwnd, hwndNextViewer, ccb);
printf("!XS(ClipboardViewerWndProc): ClipboardViewer is now: %ld\n", GetClipboardViewer());
#endif
// ChangeClipboardChain(hwnd, hwndNextViewer);
CloseHandle(hEvt);
// ExitThread(0);
PostQuitMessage(0);
break;
case WM_QUIT:
#ifdef WIN32__CLIPBOARD__DEBUG
printf("!XS(ClipboardViewerWndProc): got WM_QUIT\n");
printf("!XS(ClipboardViewerWndProc): ClipboardViewer is now: %ld\n", GetClipboardViewer());
#endif
break;
default:
#ifdef WIN32__CLIPBOARD__DEBUG
printf("!XS(ClipboardViewerWndProc): got %d\n", uMsg);
#endif
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
return (LRESULT) NULL;
}
// msgs: 36, 129, 131, 1, 776
// 24, 81, 83, 1, 308
/* ClipboardViewer Thread Function */
DWORD WINAPI ClipboardViewer(LPVOID hEvt) {
WNDCLASSEX wcx;
MSG msg;
HWND hwnd;
int stayhere;
ZeroMemory(&wcx, sizeof(WNDCLASSEX));
wcx.cbSize = sizeof(WNDCLASSEX);
wcx.lpfnWndProc = ClipboardViewerWndProc;
wcx.lpszClassName = "PERL-CLIPBOARD-VIEWER";
if(RegisterClassEx(&wcx)) {
if(hwnd = CreateWindowEx(
0,
wcx.lpszClassName,
"", 0,
1, 1, 1, 1,
NULL, // perl_hwnd,
NULL, NULL, NULL)
) {
hwndThisViewer = hwnd;
// manage the window
stayhere = 1;
while (stayhere) {
stayhere = GetMessage(&msg, hwnd, 0, 0);
if(stayhere == -1) {
stayhere = 0;
} else {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return 1;
} else {
#ifdef WIN32__CLIPBOARD__DEBUG
printf("!XS(ClipboardViewer): CreateWindowEx FAILED (%d)\n", GetLastError());
#endif
}
} else {
#ifdef WIN32__CLIPBOARD__DEBUG
printf("!XS(ClipboardViewer): RegisterClassEx FAILED (%d)\n", GetLastError());
#endif
}
return 0;
}
HANDLE StartClipboardViewer() {
DWORD CBVid;
HANDLE CBVhandle;
hEvt = CreateEvent(NULL, TRUE, TRUE, "PERL_CLIPBOARD_VIEWER");
#ifdef WIN32__CLIPBOARD__DEBUG
// printf("!XS(StartClipboardViewer): hEvt=%ld\n", hEvt);
#endif
CBVhandle = CreateThread(
NULL, 0,
(LPTHREAD_START_ROUTINE) ClipboardViewer,
NULL,
0,
&CBVid
);
if(CBVhandle == NULL) {
#ifdef WIN32__CLIPBOARD__DEBUG
printf("!XS(StartClipboardViewer): CreateThread FAILED (%d)\n", GetLastError());
#endif
return NULL;
} else {
#ifdef WIN32__CLIPBOARD__DEBUG
printf("!XS(StartClipboardViewer): Thread created (%ld)\n", CBVhandle);
#endif
return CBVhandle;
}
}
long
constant(char *name, int arg)
{
errno = 0;
if (strEQ(name, "CF_TEXT"))
#ifdef CF_TEXT
return CF_TEXT;
#else
goto not_there;
#endif
if (strEQ(name, "CF_BITMAP"))
#ifdef CF_BITMAP
return CF_BITMAP;
#else
goto not_there;
#endif
if (strEQ(name, "CF_METAFILEPICT"))
#ifdef CF_METAFILEPICT
return CF_METAFILEPICT;
#else
goto not_there;
#endif
if (strEQ(name, "CF_SYLK"))
#ifdef CF_SYLK
return CF_SYLK;
#else
goto not_there;
#endif
if (strEQ(name, "CF_DIF"))
#ifdef CF_DIF
return CF_DIF;
#else
goto not_there;
#endif
if (strEQ(name, "CF_TIFF"))
#ifdef CF_TIFF
return CF_TIFF;
#else
goto not_there;
#endif
if (strEQ(name, "CF_OEMTEXT"))
#ifdef CF_OEMTEXT
return CF_OEMTEXT;
#else
goto not_there;
#endif
if (strEQ(name, "CF_DIB"))
#ifdef CF_DIB
return CF_DIB;
#else
goto not_there;
#endif
if (strEQ(name, "CF_PALETTE"))
#ifdef CF_PALETTE
return CF_PALETTE;
#else
goto not_there;
#endif
if (strEQ(name, "CF_PENDATA"))
#ifdef CF_PENDATA
return CF_PENDATA;
#else
goto not_there;
#endif
if (strEQ(name, "CF_RIFF"))
#ifdef CF_RIFF
return CF_RIFF;
#else
goto not_there;
#endif
if (strEQ(name, "CF_WAVE"))
#ifdef CF_WAVE
return CF_WAVE;
#else
goto not_there;
#endif
if (strEQ(name, "CF_UNICODETEXT"))
#ifdef CF_UNICODETEXT
return CF_UNICODETEXT;
#else
goto not_there;
#endif
if (strEQ(name, "CF_ENHMETAFILE"))
#ifdef CF_ENHMETAFILE
return CF_ENHMETAFILE;
#else
goto not_there;
#endif
if (strEQ(name, "CF_HDROP"))
#ifdef CF_HDROP
return CF_HDROP;
#else
goto not_there;
#endif
if (strEQ(name, "CF_LOCALE"))
#ifdef CF_LOCALE
return CF_LOCALE;
#else
goto not_there;
#endif
errno = EINVAL;
return 0;
not_there:
errno = ENOENT;
return 0;
}
int
study_dib(HANDLE h, PBITMAPFILEHEADER p_hdr)
{
LPBITMAPINFO bmi;
int bitCount;
int clrUsed;
int mask_bytes = 0;
int rgbquad_array_length;
int dib_offset, dib_size;
bmi = (LPBITMAPINFO) h;
bitCount = bmi->bmiHeader.biBitCount;
clrUsed = bmi->bmiHeader.biClrUsed;
if ( bitCount == 16 || bitCount == 32 ) mask_bytes = 12;
if ( bitCount < 16 && clrUsed == 0 )
rgbquad_array_length = 1 << bitCount;
else
rgbquad_array_length = clrUsed;
dib_offset = bmi->bmiHeader.biSize + mask_bytes +
rgbquad_array_length * sizeof(RGBQUAD);
dib_size = dib_offset + bmi->bmiHeader.biSizeImage;
p_hdr->bfType = 0x4d42; /* 0x42 = "B" 0x4d = "M" */
p_hdr->bfSize = (DWORD) (sizeof(BITMAPFILEHEADER) + dib_size);
p_hdr->bfReserved1 = 0;
p_hdr->bfReserved2 = 0;
p_hdr->bfOffBits = (DWORD) (sizeof(BITMAPFILEHEADER) + dib_offset);
return dib_size;
}
MODULE = Win32::Clipboard PACKAGE = Win32::Clipboard
PROTOTYPES: DISABLE
long
constant(name, arg)
char *name
int arg
CODE:
RETVAL = constant(name, arg);
OUTPUT:
RETVAL
void
StartClipboardViewer(...)
PPCODE:
if(hThread == NULL)
hThread = StartClipboardViewer();
void
StopClipboardViewer(...)
PPCODE:
char NextText[1024];
if(hwndThisViewer) {
#ifdef WIN32__CLIPBOARD__DEBUG
printf("XS(StartClipboardViewer): hwndThisViewer=%ld\n", hwndThisViewer);
printf("XS(StartClipboardViewer): hwndNextViewer=%ld\n", hwndNextViewer);
#endif
GetWindowText(hwndNextViewer, NextText, 1024);
// DestroyWindow(hwndThisViewer);
SendMessage(hwndThisViewer, WM_DESTROY, 0, 0);
SendMessage(hwndThisViewer, WM_QUIT, 0, 0);
// PostQuitMessage(0);
// ChangeClipboardChain(hwndThisViewer, hwndNextViewer);
if(IsWindow(hwndThisViewer)) {
XSRETURN_IV((long) -1);
} else {
hwndThisViewer = NULL;
XSRETURN_YES;
}
} else {
XSRETURN_NO;
}
void
WaitForChange(...)
PPCODE:
DWORD cause;
DWORD timeout;
if(hThread == NULL) {
#ifdef WIN32__CLIPBOARD__DEBUG
printf("XS(WaitForChange): Starting the clipboard viewer...\n");
#endif
hThread = StartClipboardViewer();
}
// set the event to be waited for
ResetEvent(hEvt);
timeout = INFINITE;
if(items == 1 && !SvROK(ST(0))) { timeout = (DWORD)SvIV(ST(0)); }
if(items == 2) { timeout = (DWORD)SvIV(ST(1)); }
cause = WaitForSingleObject(hEvt, timeout);
EXTEND(SP,1);
if(cause == WAIT_OBJECT_0)
XST_mIV(0, 1);
else if ( cause == WAIT_TIMEOUT )
XST_mIV(0, 0);
else
XST_mNO(0);
XSRETURN(1);
void
GetText(...)
PPCODE:
HANDLE myhandle;
if(OpenClipboard(NULL)) {
EXTEND(SP,1);
if(myhandle = GetClipboardData(CF_TEXT))
XST_mPV(0, (char *) myhandle);
else
XST_mNO(0);
CloseClipboard();
XSRETURN(1);
} else {
XSRETURN_NO;
}
void
GetFiles(...)
PPCODE:
HANDLE myhandle;
LPTSTR filename;
UINT namelength;
UINT i, toreturn;
UINT count;
if ( OpenClipboard(NULL) ) {
if ( myhandle = GetClipboardData(CF_HDROP) ) {
count = DragQueryFile((HDROP) myhandle, 0xFFFFFFFF, NULL, 0);
EXTEND(SP, count);
for ( i = 0 ; i < count ; i++ ) {
namelength = DragQueryFile((HDROP) myhandle, i, NULL, 0);
filename = (LPTSTR) safemalloc(namelength+1);
DragQueryFile((HDROP) myhandle, i, filename, namelength+1);
XST_mPV(i, (char *)filename);
safefree(filename);
}
toreturn = count;
}
else {
EXTEND(SP, 1);
XST_mNO(0);
toreturn = 1;
}
CloseClipboard();
XSRETURN(toreturn);
}
else {
XSRETURN_NO;
}
void
GetBitmap(...)
PPCODE:
HANDLE myhandle;
BITMAPFILEHEADER hdr;
SV* buffer;
int dib_size;
if ( OpenClipboard(NULL) ) {
if( myhandle = GetClipboardData(CF_DIB) ) {
dib_size = study_dib(myhandle, &hdr);
/* Copy the BITMAPFILEHEADER */
buffer = sv_2mortal(newSVpvn((char *) &hdr,
sizeof(BITMAPFILEHEADER)));
/* Copy the DIB data */
sv_catpvn(buffer, (char *) myhandle, dib_size);
CloseClipboard();
EXTEND(SP, 1);
XPUSHs(buffer);
XSRETURN(1);
} else {
CloseClipboard();
XSRETURN_NO;
}
} else {
XSRETURN_NO;
}
void
GetAs(self=NULL, format)
SV* self;
int format;
PPCODE:
HANDLE myhandle;
LPTSTR filename;
UINT namelength;
UINT toret;
UINT count;
UINT i;
BITMAPFILEHEADER hdr;
int dib_size;
SV* buffer;
if(items == 1) format = (int)SvIV(ST(0));
if ( OpenClipboard(NULL) ) {
switch ( format ) {
case CF_HDROP:
if(myhandle = GetClipboardData(CF_HDROP)) {
count = DragQueryFile((HDROP) myhandle, 0xFFFFFFFF, NULL, 0);
EXTEND(SP, count);
for ( i = 0 ; i < count ; i++ ) {
namelength = DragQueryFile((HDROP) myhandle, i, NULL, 0);
filename = (LPTSTR) safemalloc(namelength+1);
DragQueryFile((HDROP) myhandle, i, filename, namelength+1);
XST_mPV(i, (char *)filename);
safefree(filename);
}
toret = count;
}
else {
EXTEND(SP, 1);
XST_mNO(0);
toret = 1;
}
break;
case CF_DIB:
if ( myhandle = GetClipboardData(CF_DIB) ) {
dib_size = study_dib(myhandle, &hdr);
/* Copy the BITMAPFILEHEADER */
buffer = sv_2mortal(newSVpvn((char *) &hdr,
sizeof(BITMAPFILEHEADER)));
/* Copy the DIB data */
sv_catpvn(buffer, (char *) myhandle, dib_size);
CloseClipboard();
EXTEND(SP, 1);
XPUSHs(buffer);
XSRETURN(1);
} else {
CloseClipboard();
}
break;
case CF_UNICODETEXT:
EXTEND(SP, 1);
if (myhandle = GetClipboardData(CF_UNICODETEXT))
XST_mPVN(0, (char*)myhandle, wcslen((wchar_t*)myhandle) * sizeof(wchar_t));
else
XST_mNO(0);
toret = 1;
break;
default:
EXTEND(SP, 1);
if(myhandle = GetClipboardData((UINT) format))
XST_mPV(0,(char *) myhandle);
else
XST_mNO(0);
toret = 1;
break;
}
CloseClipboard();
XSRETURN(toret);
}
XSRETURN_NO;
void
Set(text, ...)
SV *text
PPCODE:
HANDLE myhandle;
HGLOBAL hGlobal;
LPTSTR szString;
char *str;
STRLEN leng;
if (items > 1)
text = ST(1);
str = SvPV(text, leng);
if ( hGlobal = GlobalAlloc(GMEM_DDESHARE, (leng+1)*sizeof(char)) ) {
szString = (char *) GlobalLock(hGlobal);
memcpy(szString, str, leng*sizeof(char));
szString[leng] = (char) 0;
GlobalUnlock(hGlobal);
if ( OpenClipboard(NULL) ) {
EmptyClipboard();
myhandle = SetClipboardData(CF_TEXT, (HANDLE) hGlobal);
CloseClipboard();
if ( myhandle ) {
XSRETURN_YES;
} else {
#ifdef WIN32__CLIPBOARD__DEBUG
printf("XS(Set): SetClipboardData failed (%d)\n",
GetLastError());
#endif
XSRETURN_NO;
}
}
else {
#ifdef WIN32__CLIPBOARD__DEBUG
printf("XS(Set): OpenClipboard failed (%d)\n", GetLastError());
#endif
GlobalFree(hGlobal);
XSRETURN_NO;
}
}
else {
#ifdef WIN32__CLIPBOARD__DEBUG
printf("XS(Set): GlobalAlloc failed (%d)\n", GetLastError());
#endif
XSRETURN_NO;
}
void
Empty(...)
PPCODE:
if(OpenClipboard(NULL)) {
if(EmptyClipboard()) {
CloseClipboard();
XSRETURN_YES;
} else {
CloseClipboard();
XSRETURN_NO;
}
}
void
EnumFormats(...)
PPCODE:
UINT format;
int count;
if ( OpenClipboard(NULL) ) {
format = EnumClipboardFormats(0);
count = 0;
while ( format != 0 ) {
XST_mIV(count++, (long) format);
format = EnumClipboardFormats(format);
}
CloseClipboard();
}
else {
XSRETURN_NO;
}
XSRETURN(count);
void
IsFormatAvailable(svformat, ...)
SV *svformat
PPCODE:
if (items > 1)
svformat = ST(1);
XST_mIV(0, (long) IsClipboardFormatAvailable((UINT) SvIV(svformat)));
XSRETURN(1);
long
IsText(...)
CODE:
RETVAL = (long) IsClipboardFormatAvailable(CF_TEXT);
OUTPUT:
RETVAL
long
IsBitmap(...)
CODE:
RETVAL = (long) IsClipboardFormatAvailable(CF_DIB);
OUTPUT:
RETVAL
long
IsFiles(...)
CODE:
RETVAL = (long) IsClipboardFormatAvailable(CF_HDROP);
OUTPUT:
RETVAL
void
GetFormatName(svformat, ...)
SV *svformat
PPCODE:
char * name[1024];
if (items > 1)
svformat = ST(1);
if ( GetClipboardFormatName((UINT) SvIV(svformat), (LPTSTR) name, 1024) ) {
EXTEND(SP, 1);
XST_mPV(0, (char *) name);
XSRETURN(1);
}
else {
XSRETURN_NO;
}