It doesn't seem to be the case currently.
Win32::Clipboard only supports a fixed set of constants and does not pass other formats to the Win32 API.
See this bug report, made just now.
As a fun exercise, I wrote the following:
#!perl -w
use strict;
use Win32::API;
use Win32::Clipboard;
use 5.006;
our $registerClipboardFormat = Win32::API::More->new(
'user32', 'RegisterClipboardFormat', 'P', 'I'
);
die "$^E"
unless $registerClipboardFormat;
#int WINAPI GetClipboardFormatName(
# _In_ UINT format,
# _Out_ LPTSTR lpszFormatName,
# _In_ int cchMaxCount
#);
our $_getClipboardFormatName = Win32::API::More->new(
'user32', 'GetClipboardFormatName', 'IPI', 'I'
);
die "$^E"
unless $_getClipboardFormatName;
sub getClipboardFormatName {
my( $format ) = @_;
my $buffer = "\0" x 1024;
my $addr = unpack 'I', pack 'P', $buffer;
#print $addr;
warn $format;
return "<builtin format>" if $format < 17; # CF_MAX
$_getClipboardFormatName->Call( $format, $buffer, length $buffer )
or die $^E;
$buffer =~ s/\0+$//;
$buffer
}
our $CF_HTML;
sub CF_HTML() {
$CF_HTML ||= do {
$registerClipboardFormat->Call("HTML Format");
};
}
my $cb = Win32::Clipboard->new();
for my $fmt ($cb->EnumFormats()) {
print getClipboardFormatName( $fmt ), "\n";
};
warn "Retrieving as " . CF_HTML();
print $cb->GetAs(CF_HTML());
print "\ndone\n";
This code lists the names and also fetches the custom formats. I plan to do this as a patch to Win32::Clipboard, but currently don't have the time, sorry. |