473,379 Members | 1,262 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 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 3235
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Risto Heinonen | last post by:
Hi. I have a web page that has images and text. I can carefully select one image and the on the right of the image and then copy & paste to Word. Is it possible to make javascript do the same:...
2
by: adam | last post by:
I have been using the windows clipboard during some SERVER processing on a page request. It has worked on another machine but now calling Clipboard.GetDataObject() returns null. The code is...
1
by: andrew | last post by:
I have a MSchart object (COM Component) which I wish to insert as an image into a picture box so that I can print it out. 'I call the chart controls's EditCopy to pass data to the clipboard. ...
5
by: DraguVaso | last post by:
Hi, I'm looking for a way to Copy and Paste Files to the clipboard. I found a lot of articles to copy pieces of text and bitmaps etc, but nog whole files. Whay I need is like you have in...
2
by: Keith | last post by:
I'm trying to come up with a way to create a contextmenu that will do all the "standard" functions (cut, copy, paste, undo, etc). There seems to be a lot of information out there - but nothing...
7
by: lgbjr | last post by:
Hello All, Im using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard...
3
by: MLH | last post by:
Say I have a string value in Access - perhaps "ABCDE". How do I copy it to Windoze clipboard? This is not a repost, but is related to a 7/26/06 post entitled "Probs running DoCmd.RunCommand...
9
by: Alan T | last post by:
Any source code example I can use to save the clipboard content to an object, then I will do a copy and paste, finally put back the 'saved' clipboard content back to clipboard ?
0
by: Curious | last post by:
I'm working on fixing the command of "Copy to Clipboard" from a data grid. The current implementation has two problems: 1) There are two extra columns copied to clipboard that are invisible...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.