Click to See Complete Forum and Search --> : Accessing Ciploard fom a service


Sephral
November 25th, 2001, 07:48 AM
Hi,
i have a problem accessing the Clipboard out of a Win32 service (Windows 2000).
My Service is of Type "SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS" and i use UNICODE. I try to access the Clipboard that way:


void ReadAndPlay()
{
char *buffer = NULL;
HANDLE hData;
if ( OpenClipboard(NULL) )
{
hData= GetClipboardData( CF_TEXT );
buffer = (char*)GlobalLock( hData );
EmptyClipboard();
GlobalUnlock( hData );
CloseClipboard();

if(buffer!=NULL){
EncodeString(buffer); //<--Encode the clipboard string
}
}
else Beep(2000,1000); //<-- for debugging

}



I *know* thereīs some Text in the Clipboard, but "if(buffer!=NULL)" allways fails -> thereīs no text. I think i canīt access the Clipboard of the current User or i need somethink like "CF_TEXT" for UNICODE.

The code works fine in a normal console application w/o Unicode....

Any Ideas?

Thank you,
Sephral