This isn't something that can be easily done with win32::API.

If you are setup to build your own packages, you could try applying the following patch to Win32::Clipboard v0.52. It adds a SetFiles() method. It includes the code changes plus an extra test, but no changes to the documentation.

If it proves usable I'll offer it to the owner, but be prepared to back it out. XS isn't my thing.

diff -uiwr Win32-Clipboard-0.52\Clipboard.pm Win32-Clipboard-0.53-save +d\Clipboard.pm --- Win32-Clipboard-0.52\Clipboard.pm Fri Sep 10 16:05:35 2004 +++ Win32-Clipboard-0.53-saved\Clipboard.pm Fri Oct 14 07:01:43 200 +5 @@ -3,10 +3,11 @@ # # Win32::Clipboard - Interaction with the Windows clipboard # -# Version: 0.52 +# Version: 0.53 # Author: Aldo Calpini <dada@perl.it> # # Modified by: Hideyo Imazu <himazu@gmail.com> +# BrowserUk@perlmonks 14 October 2005 Added SetFiles # ##################################################################### +## @@ -65,7 +66,7 @@ ##################################################################### +## # STATIC OBJECT PROPERTIES # -$VERSION = "0.52"; +$VERSION = "0.53"; ##################################################################### +## # FUNCTIONS diff -uiwr Win32-Clipboard-0.52\Clipboard.xs Win32-Clipboard-0.53-save +d\Clipboard.xs --- Win32-Clipboard-0.52\Clipboard.xs Sat Jul 24 09:47:05 2004 +++ Win32-Clipboard-0.53-saved\Clipboard.xs Fri Oct 14 07:00:04 200 +5 @@ -3,12 +3,13 @@ # # Win32::Clipboard - Interaction with the Windows clipboard # -# Version: 0.52 +# Version: 0.53 # Created: 19 Nov 96 # Author: Aldo Calpini <dada@divinf.it> # # Modified: 24 Jul 2004 # By: Hideyo Imazu <h@imazu.net> +# BrowserUk@perlmonks 14 October 2005 Added SetFiles # ##################################################################### +## */ @@ -630,6 +631,69 @@ } void +SetFiles(...) +PPCODE: + HANDLE myhandle; + HGLOBAL hGlobal; + LPTSTR szString; + SV* sv; + int leng = 16; // DROPFILES header + int index; + if(!items) { + XSRETURN_UNDEF; + } + for( index=1; index < items; index++ ) { + sv = ST(index); + leng += SvCUR( sv ); + } + leng += index * 2 +10; + if ( hGlobal = GlobalAlloc(GMEM_DDESHARE, (leng)*sizeof(char)) ) +{ + char* sz = szString = (char *) GlobalLock(hGlobal); + memset( szString, 0, leng );; + + *((INT*)szString) = 20l; // offset to star +t of list + szString += 20l; + + for( index=1; index<items; index++ ) { + sv = ST(index); + leng = SvCUR( sv ); + memcpy(szString, (char *) SvPV_nolen( sv ), leng*sizeof(c +har)); + szString += leng + 1; + } + + GlobalUnlock(hGlobal); + + if ( OpenClipboard(NULL) ) { + EmptyClipboard(); + myhandle = SetClipboardData( CF_HDROP, (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", GetLastErr +or()); +#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)) { diff -uiwr Win32-Clipboard-0.52\Makefile Win32-Clipboard-0.53-saved\Ma +kefile --- Win32-Clipboard-0.52\Makefile Sat Jul 24 09:48:51 2004 +++ Win32-Clipboard-0.53-saved\Makefile Fri Oct 14 04:45:51 2005 @@ -55,11 +55,11 @@ DIRFILESEP = ^\ NAME = Win32::Clipboard NAME_SYM = Win32_Clipboard -VERSION = 0.52 +VERSION = 0.53 VERSION_MACRO = VERSION -VERSION_SYM = 0_52 +VERSION_SYM = 0_53 DEFINE_VERSION = -D$(VERSION_MACRO)=\"$(VERSION)\" -XS_VERSION = 0.52 +XS_VERSION = 0.53 XS_VERSION_MACRO = XS_VERSION XS_DEFINE_VERSION = -D$(XS_VERSION_MACRO)=\"$(XS_VERSION)\" INST_ARCHLIB = blib\arch @@ -251,7 +245,7 @@ DIST_CP = best DIST_DEFAULT = tardist DISTNAME = Win32-Clipboard -DISTVNAME = Win32-Clipboard-0.52 +DISTVNAME = Win32-Clipboard-0.53 # --- MakeMaker macro section: @@ -502,7 +496,7 @@ $(NOECHO) $(ECHO) "# http://module-build.sourceforge.net/META-spe +c.html" > META.yml $(NOECHO) $(ECHO) "#XXXXXXX This is a prototype!!! It will chang +e in the future!!! XXXXX#" >> META.yml $(NOECHO) $(ECHO) "name: Win32-Clipboard" >> META.yml - $(NOECHO) $(ECHO) "version: 0.52" >> META.yml + $(NOECHO) $(ECHO) "version: 0.53" >> META.yml $(NOECHO) $(ECHO) "version_from: Clipboard.pm" >> META.yml $(NOECHO) $(ECHO) "installdirs: site" >> META.yml $(NOECHO) $(ECHO) "requires:" >> META.yml @@ -824,7 +818,7 @@ # --- MakeMaker ppd section: # Creates a PPD (Perl Package Description) for a binary distribution. ppd: - $(NOECHO) $(ECHO) "<SOFTPKG NAME=\"$(DISTNAME)\" VERSION=\"0,52,0 +,0\">" > $(DISTNAME).ppd + $(NOECHO) $(ECHO) "<SOFTPKG NAME=\"$(DISTNAME)\" VERSION=\"0,53,0 +,0\">" > $(DISTNAME).ppd $(NOECHO) $(ECHO) " <TITLE>$(DISTNAME)</TITLE>" >> $(DISTNAME) +.ppd $(NOECHO) $(ECHO) " <ABSTRACT>Interaction with the Windows cli +pboard</ABSTRACT>" >> $(DISTNAME).ppd $(NOECHO) $(ECHO) " <AUTHOR>Aldo Calpini &lt;dada@perl.it&gt;< +/AUTHOR>" >> $(DISTNAME).ppd diff -uiwr Win32-Clipboard-0.52\META.yml Win32-Clipboard-0.53-saved\ME +TA.yml --- Win32-Clipboard-0.52\META.yml Fri Sep 10 16:08:05 2004 +++ Win32-Clipboard-0.53-saved\META.yml Thu Oct 13 19:32:49 2005 @@ -1,7 +1,7 @@ # http://module-build.sourceforge.net/META-spec.html #XXXXXXX This is a prototype!!! It will change in the future!!! XXXX +X# name: Win32-Clipboard -version: 0.52 +version: 0.53 version_from: Clipboard.pm installdirs: site requires: diff -uiwr Win32-Clipboard-0.52\t\test.t Win32-Clipboard-0.53-saved\t\ +test.t --- Win32-Clipboard-0.52\t\test.t Sat Mar 11 15:51:26 2000 +++ Win32-Clipboard-0.53-saved\t\test.t Fri Oct 14 04:45:34 2005 @@ -3,11 +3,11 @@ # `make test'. After `make install' it should work as `perl test.pl' use strict; -use vars qw( $loaded $clip $actual ); +use vars qw( $loaded $clip $actual @actual ); ######################### We start with some black magic to print on +failure. -BEGIN { $| = 1; print "1..9\n"; } +BEGIN { $| = 1; print "1..10\n"; } END {print "not ok 1\n" unless $loaded;} use Win32::Clipboard; $loaded = 1; @@ -31,22 +31,27 @@ print "not " unless $clip->Get() eq ""; print "ok 5\n"; +$clip->SetFiles( qw[ 1.dat 2.dat 3.dat 4.dat 5.dat ] ); +@actual = $clip->GetFiles(); +print "not " unless "@actual" eq "1.dat 2.dat 3.dat 4.dat 5.dat"; +print "ok 6\n"; + undef $clip; tie $clip, 'Win32::Clipboard'; print "not" unless tied($clip) and ref(tied($clip)) =~ /Win32::Clipbo +ard/; -print "ok 6\n"; +print "ok 7\n"; $clip = "Win32::Clipboard test"; $actual = $clip; print "not " unless $actual eq "Win32::Clipboard test"; -print "ok 7\n"; +print "ok 8\n"; tied($clip)->Empty(); print "not " unless $clip eq ""; -print "ok 8\n"; +print "ok 9\n"; $clip = "Win32::Clipboard test"; print "not " unless tied($clip)->IsText(); -print "ok 9\n"; \ No newline at end of file +print "ok 10\n";

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.

In reply to Re: Move/Copy files using Clipboard! by BrowserUk
in thread Move/Copy files using Clipboard! by Ace128

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.