🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #8436

Re: Writing to Clipboard from a service

#8436
From: Malcolm Smith
Date: Sat, 23 Oct 2004 01:44
60 lines
2828 bytes
Which account does the service log on with ?

How do you know when to write to the clipboard ?

-- 
Malcolm Smith
MJ Freelancing
http://www.mjfreelancing.com
Borland Technology Partner

Contributing Editor
C++Builder Developers Journal
http://bcbjournal.org


"nicolasr" <nicolasrNOSPAMATSIGNgmx.net> wrote in message
news:4179a85e$1@newsgroups.borland.com...
> Hi,
>
> I want to write to the Clipboard of the currently
> logged on user from within a Windows service.
>
> I've created the service with BCBs TService class.
> To write to the clipboard I first tried the global
> TClipboard instance. Since this didn't work I tried
> to use the APIs directly, as described in the MSDN help.
>
> Like this:
>
>       if(FALSE == OpenClipboard(NULL))
>       {
>          Log("OpenClipboard failed");
>          return;
>       }
>
>       HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, dataSize+1);
>
>       void* ptr = GlobalLock(hGlobal);
>       CopyMemory(ptr, buffer, dataSize+1);
>
>       if(FALSE == SetClipboardData(CF_TEXT, hGlobal))
>          Log(GetLastErrorString());
>
>       GlobalUnlock(hGlobal);
>       GlobalFree(hGlobal);
>
>       CloseClipboard();
>
> However, the text never arrives in the clipboard. The problem
> is that I don't get any error log so I don't know what went wrong.
> I'm not very familiar with security issues so I don't know whether
> the service can write to the clipboard at all.
>
> By the way, I switched the services Interactive property to 'true'
> but that didn't help.
>
> Any ideas welcome!
> Nick
>
>
Technical Details
Message-ID: <4179b6ca@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!solnet.ch!solnet.ch!news2.euro.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!news-hub.cableinet.net!blueyonder!news-peer-test!btnet!newsfeed.bt.es!195.5.65.34.MISMATCH!caladan.arrakis.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <4179a85e$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,f2ddb07f5aa054ba
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
Reply-To: "Malcolm Smith" <mjfreelancing@optusnet.com.au>
From: "Malcolm Smith" <mjfreelancing@optusnet.com.au>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <4179a85e$1@newsgroups.borland.com>
Subject: Re: Writing to Clipboard from a service
Date: Sat, 23 Oct 2004 11:44:34 +1000
Lines: 62
Organization: MJ Freelancing
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
NNTP-Posting-Host: 211.30.147.112
Message-ID: <4179b6ca@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1098495690 211.30.147.112 (22 Oct 2004 18:41:30 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!solnet.ch!solnet.ch!news2.euro.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!news-hub.cableinet.net!blueyonder!news-peer-test!btnet!newsfeed.bt.es!195.5.65.34.MISMATCH!caladan.arrakis.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail