472,146 Members | 1,390 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,146 software developers and data experts.

How to copy to the Clipboard and make data public

I am trying to write a method to copy some text to the clipboard, and leave
a copy of it there after the application has exited.

Sub CopyToClipboard(ByVal value As Object)
Dim data As New DataObject()
data.SetData(DataFormats.UnicodeText, True, value)
Clipboard.SetDataObject(data,True)
End Sub

When I test it, I get an exception:

System.Runtime.InteropServices.ExternalException: The requested clipboard
operation failed.
at System.Windows.Forms.Clipboard.ThrowIfFailed(Int32 hr)
at System.Windows.Forms.Clipboard.SetDataObject(Objec t data, Boolean
copy)
at ClipName.PublicClipboard.CopyToClipboard(Object value)

However, the exception can be avoided if the Copy option is dropped from the
Clipboard.SetDataObject() method, but then the data is not available after
the application exits.
From this I guess the problem must be a matter of security.
Can someone tell me if it is indeed a security problem?
(and any pointers, as I am new to .NET security)
--
Thanks for any help,
Shayne H
Nov 20 '05 #1
2 3164
Hi, I could not repo your issue on Visual Studio .NET 2003.

Would you tell me what you passed in as 'value' for 'CopyToClipboard'?

Thanks,

--
Huy Nguyen, Visual Basic team.

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they
originated.

Nov 20 '05 #2
I was passing a string.
However now I cannot reproduce the problem either.

"Huy Nguyen [MSFT]" <hu**@online.microsoft.com> wrote in message
news:9o*************@cpmsftngxa07.phx.gbl...
Hi, I could not repo your issue on Visual Studio .NET 2003.

Would you tell me what you passed in as 'value' for 'CopyToClipboard'?

Thanks,

--
Huy Nguyen, Visual Basic team.

This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they
originated.

Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Risto Heinonen | last post: by
2 posts views Thread by adam | last post: by
1 post views Thread by andrew | last post: by
2 posts views Thread by Keith | last post: by
7 posts views Thread by lgbjr | last post: by
9 posts views Thread by Alan T | last post: by
reply views Thread by Curious | last post: by
reply views Thread by Saiars | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.