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 musing on the Monastery: (3)
As of 2014-09-21 07:55 GMT
Find Nodes?
    Voting Booth?

    How do you remember the number of days in each month?

    Results (167 votes), past polls