剪贴板复制粘贴在 Win Server 2008/Vista 64 位服务中不起作用 [英] Clipboard Copy-Paste doesn't work in a service on Win Server 2008/Vista 64bit

查看:27
本文介绍了剪贴板复制粘贴在 Win Server 2008/Vista 64 位服务中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:此问题已解决.

您可以在此处阅读有关解决方案的信息:创建一个在 windows-2008-server 中的服务的非零会话中处理?

you can read about the solution in here: Creating a process in a non-zero session from a service in windows-2008-server?

谢谢大家!

我正在尝试使用 Clipboard API(在 Delphi 中)从 Word 文档中提取图像.我的代码在 Windows XP/2003 中可以正常工作,但在 Windows 2008 64 位中它不起作用.在 win 2008 中,我收到一条错误消息,提示 Clipboard.Formats 为空且不包含任何格式.

I am trying to use Clipboard API (in Delphi) to extract images from Word documents. my code works OK in Windows XP/2003 but in windows 2008 64 bit it doesn't work. in win 2008 i get an error saying that Clipboard.Formats is empty and doesn't contain any format.

图像似乎被复制到剪贴板(我可以通过 Word 在剪贴板中看到它)但是当我尝试询问剪贴板时,他说它没有任何格式.

The image seems to be copied to the Clipboard (i can see it in the clipboard via Word) but when i try to ask the clipboard what format does he have it said it doesn't have any formats.

如何在 win 2008/Vista 上以编程方式访问剪贴板?据我所知 2008 64 位,这可能是一个安全问题...

how can i access the clipboard programmatically on win 2008/Vista? from what i know of 2008 64 bit, it might be a security issue...

这是代码片段:

这是我尝试将图像复制到剪贴板的方式:

This is how i am trying to copy the Image to the clipboard:

W.ActiveDocument.InlineShapes.Item(1).Select; // W is a word ole object
W.Selection.Copy;

这就是我尝试粘贴它的方式.

and this is how i try to paste it.

  Clipboard.Open;
      Write2DebugFile('FormatCount = ' + IntToStr(Clipboard.FormatCount)); // FormatCount=0 
      For JJ := 1 to Clipboard.FormatCount Do
          Write2DebugFile('#'+ IntToStr(JJ) + ':' + IntToStr(Clipboard.Formats[JJ]));
      If (Clipboard.HasFormat(CF_BITMAP)) or
        (Clipboard.HasFormat(CF_PICTURE)) or
        (Clipboard.HasFormat(CF_METAFILEPICT)) then    // all HasFormat calls returns false.
      Begin
       Jpeg := TJPEGImage.Create;
       Bitmap := TBitmap.Create;
       Bitmap.LoadFromClipboardFormat(cf_BitMap,ClipBoard.GetAsHandle(cf_Bitmap),0);
       Jpeg.Assign(Bitmap);
       Jpeg.SaveToFile(JpgFileN);
       try Jpeg.Free; except; end;
       ResizeImage(JpgFileN,750);
       Write2DebugFile('Saving ' + JpgFileN);
      End
      else  Write2DebugFile('Doesnt have the right format');

提前致谢,意大利

推荐答案

AFAIR,在 Win2008 中出现 M$ 不允许服务与桌面(使用剪贴板需要)交互.

AFAIR, appear that M$ doesn't allow services to interact with desktop (which is needed to use clipboard) in Win2008.

这篇关于剪贴板复制粘贴在 Win Server 2008/Vista 64 位服务中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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