Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

JamesNC's scratchpad

by JamesNC (Chaplain)
on Oct 07, 2004 at 04:58 UTC ( #397227=scratchpad: print w/ replies, xml ) Need Help??

#include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "ppport.h" #include <windows.h> #include <stdio.h> #include <float.h> #include <stdlib.h> #include <math.h> #include <string.h> int isFileOpen(char *filename) { HFILE theFile = HFILE_ERROR; DWORD lastErr = NO_ERROR; // Attempt to open the file exclusively. theFile = _lopen(filename, OF_READ | OF_SHARE_EXCLUSIVE); if (theFile == HFILE_ERROR) // Save last error... lastErr = GetLastError(); else // If the open was successful, close the file. _lclose(theFile); // Return TRUE if there is a sharing-violation. if ((theFile == HFILE_ERROR) && (lastErr == ERROR_SHARING_VIOLATION)) return 1; } int GetClipboardSize() { char *htext, *stext; if( OpenClipboard(NULL) ) htext=GetClipboardData(CF_UNICODETEXT); stext = (LPTSTR) GlobalLock((HGLOBAL) htext); GlobalUnlock((HGLOBAL) htext); return GlobalSize(htext); } void SaveClipboardToFile( char* filename ) { char *h; int i, size; FILE *f; if ( OpenClipboard(NULL) ){ h = GetClipboardData(CF_UNICODETEXT); size = GlobalSize(h); if( size > 0 ){ f = fopen(filename,"wb"); for( i = 0; i < size; i++){ fprintf( f, "%c", *(h+i) ); } fclose(f); } } } void Empty (void ) { if( OpenClipboard(NULL) ){ EmptyClipboard(); } } MODULE = Win32::Clipboard::File PACKAGE = Win32::Clipboard::Fil +e int GetClipboardSize() void SaveClipboardToFile( filename ) char *filename void Empty() int isFileOpen( filename ) char *filename
Log In?

What's my password?
Create A New User
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (12)
As of 2015-07-06 21:11 GMT
Find Nodes?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...

    Results (83 votes), past polls