如何使用C#创建自定义剪贴板 [英] How to create Custom clipboard using C#

查看:171
本文介绍了如何使用C#创建自定义剪贴板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨先生,



当两个值都在运行时,我被要求将一些值从一个EXE传递给另一个EXE。



我知道如何在打开一个新的EXE时传递参数,但我不知道它在运行时如何传递。



我的问题:



由于我使用的是.NET 2.0版本,因此不支持功能。

所以我被告知要存储在剪贴板中并通过计时器从目标EXE中检索数据



但如果用户选择我们EXE之外的任何内容,那么将会出现问题剪贴板内容将被删除,从而导致很多问题。



我通过 Google 我们可以存储自定义剪贴板数据。因此,剪贴板数据将根据该密钥存储。



我可以通过计时器检查并调用剪贴板数据,因此我可以进行干净的传输。



先生



这就是我打算说的。是否可以实现这一目标或有任何方法可以有效地做到这一点。等待您的宝贵答案。

Hi Sir,

I was asked to pass some values from One EXE to another EXE when both are running.

I know how to pass parameters when opening a new EXE but I dont know how to pass when it is running.

My Problem:

Since I am using .NET 2.0 version may features are not supported.
So I was told to store in clipboard and retrieve that data from the destination EXE by timer

But there will be a problem if user select any content outside our EXE then the clipboard content will be erased thus causing much problem.

I gone through Google that we can store custom Clipboard data. So that clipboard data will be stored based on that key.

I can check and call the clipboard data by timer and thus I can make a clean transfer.

Sir,

This is what I planned to say. Can this be achieved or is there any way to do this efficiently.Waiting for your valuable answer.

推荐答案

请不要这样做。

这是一个非常糟糕的想法,如果你的应用程序对我这样做会导致你的应用程序被终止并以极端的偏见卸载。然后我会想要我的钱。



除非用户特别要求,否则你永远不应该把任何东西放在剪贴板上:想象一下如果你是多么幸福重构你的代码并削减一大块准备将其重新粘贴下来......我的一个应用程序覆盖了剪贴板内容!我怀疑不是一个快乐的小兔子。



.NET 2包含了各种应用程序可以直接相互通信的方式,包括套接字和TCPClient,或者你甚至可以通过数据库! :笑:

其中任何一个都会比剪贴板变得更好,相信我!
Please, don't do that.
That is a seriously poor idea, which if your application did it to me would cause your application to be terminated and uninstalled with extreme prejudice. I would then want my money back.

You should never, ever put anything on the clipboard unless the user specifically requests it: image how happy you would be if you were refactoring your code and cut a big chunk ready to paste it back further down...and one of my apps overwrote the clipboard content! Not a happy bunny I suspect.

.NET 2 included loads of ways that apps could talk directly to each other including sockets and TCPClient, or you could even communicate via a database! :laugh:
Any of those will be better that faffing with the clipboard, trust me!


这篇关于如何使用C#创建自定义剪贴板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆