剪贴板复制粘贴在 Win Server 2008/Vista 64 位上的服务中不起作用
更新:此问题已解决。
您可以在此处阅读有关解决方案的信息: 创建来自 windows-2008-server 中的服务的非零会话中的进程?
谢谢大家!
你好,
我正在尝试使用 Clipboard API(在 Delphi 中)从 Word 文档中提取图像。 我的代码在 Windows XP/2003 中工作正常,但在 Windows 2008 64 位中它不起作用。 在 win 2008 中,我收到一条错误消息,指出 Clipboard.Formats 为空且不包含任何格式。
该图像似乎被复制到剪贴板(我可以通过Word在剪贴板中看到它),但是当我尝试询问剪贴板他有什么格式时,它说它没有任何格式。
如何在 win 2008/Vista 上以编程方式访问剪贴板? 据我所知 2008 64 位,这可能是一个安全问题...
这是代码片段:
这就是我尝试将图像复制到剪贴板的方式:
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');
提前致谢, 伊泰
Update: This issue has been resolved.
you can read about the solution in here:
Creating a process in a non-zero session from a service in windows-2008-server?
Thanks everyone!
Hi,
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.
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.
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...
here is the code snippet:
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
AFAIR,似乎 M$ 不允许服务与 Win2008 中的桌面交互(这是使用剪贴板所必需的)。
AFAIR, appear that M$ doesn't allow services to interact with desktop (which is needed to use clipboard) in Win2008.