剪贴板复制粘贴不会在Win Server 2008中/ Vista的64位上的服务工作剪贴板、会在、工作、Server

2023-09-08 00:44:15 作者:一生挚爱的那个男人Wbb

更新:此问题已得到解决。

Update: This issue has been resolved.

你可以看到在这里的解决方案: http://stackoverflow.com/questions/2237696/creating-a-process-in-a-non-zero-session-from-a-service-in-windows-2008-server

you can read about the solution in here: http://stackoverflow.com/questions/2237696/creating-a-process-in-a-non-zero-session-from-a-service-in-windows-2008-server

谢谢大家!

您好,

我想使用剪贴板API(在Delphi)从Word文档中提取图像。 我的code工程确定在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.

我怎样才能访问剪贴板上的编程赢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...

这里是code片断:

这是怎么我试图将图像复制到剪贴板:

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');

在此先感谢, 伊泰

Thanks in advance, Itay

推荐答案

AFAIR,看来M $不允许服务与桌面交互(这是需要使用剪贴板)在Win2008的。

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