防止在我的应用程序外粘贴 [英] Prevent Paste outside my app

查看:77
本文介绍了防止在我的应用程序外粘贴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


我正在寻找一种聪明的方法来防止有人在我的应用程序之外粘贴复制文本




我知道如何监控剪贴板并在

文本存储在剪贴板中时收到WM_DRAWCLIPBOARD消息...如果我只能检测到某种类型的
$ b剪贴板即将粘贴的$ b传出消息,然后我可以查看

查看我的应用程序当前是否处于焦点状态并根据需要允许/拒绝。


我会在应用程序失去焦点时擦除剪贴板,但我可以看到

的情况,如果用户只需点击

就会对用户造成痛苦其他地方非常快。


任何人都有任何想法吗?

谢谢大家阅读本文。


Rob K

Hello,

I am looking for a clever way to prevent someone from pasting copied text
outside of my app.

I know how to monitor the clipboard and get an WM_DRAWCLIPBOARD message when
text is stored in the clipboard... If only I could detect some kind of
outgoing message that the clipboard is about to paste, then I could check to
see if my app is currently in focus and allow/deny as necessary.

I would just erase the clipboard upon the app loosing focus, but I can see
cases where that would be a pain to the user if they just had to click
somewhere else real quick.

Anyone have any ideas?

Thank you all for reading this.

Rob K

推荐答案

这有点痛苦,但你可以为你的实现自己的剪贴板

申请。


-

杰夫rey Hornby

Hornby Consulting,Inc。


" RobKinney1"写道:
It''s kind of a pain but you could implement your own clipboard just for your
application.

--
Jeffrey Hornby
Hornby Consulting, Inc.

"RobKinney1" wrote:
您好,

我正在寻找一种聪明的方法来防止有人在我的应用程序之外粘贴复制的文本。

我知道如何监控剪贴板并在
文本存储在剪贴板中时收到WM_DRAWCLIPBOARD消息...如果我只能检测到剪贴板中的某种传出消息粘贴,然后我可以检查
看看我的应用程序当前是否在焦点,并在必要时允许/拒绝。

我只是在应用程序失去焦点时擦除剪贴板,但我可以看看
如果用户只需要在其他地方快速点击
就会给用户带来痛苦。

任何人都有任何想法吗?
谢谢大家阅读本文。

Rob K
Hello,

I am looking for a clever way to prevent someone from pasting copied text
outside of my app.

I know how to monitor the clipboard and get an WM_DRAWCLIPBOARD message when
text is stored in the clipboard... If only I could detect some kind of
outgoing message that the clipboard is about to paste, then I could check to
see if my app is currently in focus and allow/deny as necessary.

I would just erase the clipboard upon the app loosing focus, but I can see
cases where that would be a pain to the user if they just had to click
somewhere else real quick.

Anyone have any ideas?

Thank you all for reading this.

Rob K



嘿Jeffrey,


感谢您的回复。有点好笑,你提到过,因为那是我开始做的事情之前我才意识到2个不同的activeX Word

控件(来自浏览器控件)会松动它们的格式化。我无法通过我自己的剪贴板编写足够复杂的东西来保存表格,图表等等。


我还想过捕捉我的应用程序之外发生的所有CTRL + V'(
)(通过钩子),但我不能阻止用户右键点击某个地方

并点击粘贴。 (我尝试在系统范围内捕获WM_PASTE消息,但

该消息似乎不是从Word

doc复制到记事本时发送的消息: - {)。


还有其他任何想法/想法吗?


再次感谢您的回复。


Rob K


" Jeffrey Hornby"写道:
Hey Jeffrey,

Thank you for replying. Kinda funny you mentioned that, because that is
what I started doing before I realized that the 2 different activeX Word
controls (from the browser control) would loose their formating. I couldn''t
program something sophisticated enough to preserve the tables, graphs, etc,
through my own clipboard.

I also thought about capturing all CTRL+V''s that happen outside of my app
(through a hook), but I cannot prevent the user from right-clicking somewhere
and clicking paste. (I tried catching the WM_PASTE message system-wide, but
that message doesn''t seem to be what is being sent when copying from a Word
doc to Notepad :-{ ).

Any other thoughts/ideas?

Thanks again for replying.

Rob K

"Jeffrey Hornby" wrote:
这是一种痛苦,但你可以为你的
应用程序实现自己的剪贴板。

-
Jeffrey Hornby
Hornby Consulting,Inc。

RobKinney1写道:
It''s kind of a pain but you could implement your own clipboard just for your
application.

--
Jeffrey Hornby
Hornby Consulting, Inc.

"RobKinney1" wrote:
您好,

我正在寻找一种聪明的方法来防止有人在我的应用程序之外粘贴复制的文本。

我知道如何监控剪贴板并在
文本存储在剪贴板中时收到WM_DRAWCLIPBOARD消息...如果我只能检测到剪贴板中的某种传出消息粘贴,然后我可以检查
看看我的应用程序当前是否在焦点,并在必要时允许/拒绝。

我只是在应用程序失去焦点时擦除剪贴板,但我可以看看
如果用户只需要在其他地方快速点击
就会给用户带来痛苦。

任何人都有任何想法吗?
感谢大家阅读本文。

Rob K
Hello,

I am looking for a clever way to prevent someone from pasting copied text
outside of my app.

I know how to monitor the clipboard and get an WM_DRAWCLIPBOARD message when
text is stored in the clipboard... If only I could detect some kind of
outgoing message that the clipboard is about to paste, then I could check to
see if my app is currently in focus and allow/deny as necessary.

I would just erase the clipboard upon the app loosing focus, but I can see
cases where that would be a pain to the user if they just had to click
somewhere else real quick.

Anyone have any ideas?

Thank you all for reading this.

Rob K



Rob,

您可以使用某些私人剪贴板格式添加文本。


class Program

{


[STAThread]

static void Main(string [] args)

{


Clipboard.SetData(" MyFormat"," Hello World");

if(Clipboard.ContainsData(" MyFormat"))

{

Console.WriteLine(" Paste - {0}" ,

(字符串)Clipboard.GetData(" MyFormat"));

}

Console.ReadLine();

}

}


只要格式是私有的,其他任何应用程序都不会尝试

得到这个来自剪贴板的数据,但您的应用程序的两个实例可以使用它来
。为了防止你可以将另外一条信息添加到

剪贴板中,该剪贴板将是一些应用程序ID,例如:您在

应用程序启动时创建的GUID。

在从剪贴板粘贴之前,应用程序首先阅读并检查此

ID对应用程序''自己的身份证,如果他们不匹配则不要粘贴。

-

HTH

Stoitcho Goutsev(100)


" RobKinney1" <滚装******** @ discussions.microsoft.com>在消息中写道

新闻:80 ********************************** @ microsof t.com ...
Rob,

You can add the text under some private clipboard format.

class Program
{

[STAThread]
static void Main(string[] args)
{

Clipboard.SetData("MyFormat", "Hello World");
if (Clipboard.ContainsData("MyFormat"))
{
Console.WriteLine("Paste - {0}",
(string)Clipboard.GetData("MyFormat"));
}
Console.ReadLine();
}
}

As long as the format is private no other application will ever attempt to
get this data from the clipboard, but two instances of your application can
use it. To prevent that you can add one more piece of information to the
clipboard that will be some application ID, e.g. GUID that you create upon
application start.
Before pasting from the clipboard the application first read and check this
ID against application''s own ID and if they don''t match then don''t paste.
--
HTH
Stoitcho Goutsev (100)

"RobKinney1" <Ro********@discussions.microsoft.com> wrote in message
news:80**********************************@microsof t.com...
你好,

我正在寻找一种聪明的方法来防止有人在我的应用程序之外粘贴复制的文本。

我知道如何监控剪贴板并获取WM_DRAWCLIPBOARD消息

文本存储在剪贴板中时...如果我只能检测到某种传出消息剪贴板即将粘贴,然后我可以检查
以查看我的应用程序当前是否处于焦点状态并在必要时允许/拒绝。

我只是擦除剪贴板该应用程序失去了焦点,但我可以看到,如果用户只需要在其他地方快速点击
就会对用户造成痛苦。

任何人都有任何想法感谢大家阅读本文。

Rob K
Hello,

I am looking for a clever way to prevent someone from pasting copied text
outside of my app.

I know how to monitor the clipboard and get an WM_DRAWCLIPBOARD message
when
text is stored in the clipboard... If only I could detect some kind of
outgoing message that the clipboard is about to paste, then I could check
to
see if my app is currently in focus and allow/deny as necessary.

I would just erase the clipboard upon the app loosing focus, but I can see
cases where that would be a pain to the user if they just had to click
somewhere else real quick.

Anyone have any ideas?

Thank you all for reading this.

Rob K



这篇关于防止在我的应用程序外粘贴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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