更新:此问题已解决。
您可以在此处阅读有关解决方案的信息:
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为空,不包含任何格式。
该图像似乎已复制到剪贴板(我可以通过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');
提前致谢,
伊泰
最佳答案
AFAIR,看来M $在Win2008中不允许服务与桌面进行交互(使用剪贴板需要此交互)。