【问题标题】:Clipboard Copy-Paste doesn't work on Win Server 2008/Vista 64bit剪贴板复制粘贴在 Win Server 2008/Vista 64bit 上不起作用
【发布时间】:2010-02-03 14:10:21
【问题描述】:

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

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

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

这里是sn-p的代码:

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

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

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

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

提前致谢, 伊泰

【问题讨论】:

    标签: windows-server-2008 clipboard 64-bit security-policy


    【解决方案1】:

    那么,调试输出的格式列表是什么?复制和粘贴之间会发生什么样的延迟?在这些代码片段之间,您肯定需要一些空闲时间。即您不能复制然后立即期望能够粘贴。

    【讨论】:

      【解决方案2】:

      您可以使用Sharp IMG Viewer 2008 应用程序检查剪贴板格式。 .NET 应用程序可以从here 下载。您可以通过阅读文档找到更详细的信息。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-10-24
        • 1970-01-01
        • 2022-11-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多