从ActiveX(保护模式IE)保存文件的技术 [英] Techniques to save files from ActiveX (protected mode IE)

查看:260
本文介绍了从ActiveX(保护模式IE)保存文件的技术的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ActiveX.

i have an ActiveX.

ActiveX的意思是:

ActiveX means:

  • Internet Explorer
  • 本地二进制代码
  • 从dll(.ocx)运行
  • 处于保护模式
  • Internet Explorer
  • native binary code
  • running from a dll (.ocx)
  • in Protected Mode

用户想要保存一些内容.我想显示一个另存为对话框,然后保存到他们说的位置.

The user would like to save some content. i would like to show a Save As dialog, then save to the location they said.

由于托管我的ActiveX的进程以完整性级别运行,因此代码无法保存到用户请求的位置.

Since the process hosting my ActiveX is running at a Low integrity level, the code cannot save to the user's requested location.

由于托管ActiveX的进程正在Internet Explorer的保护"模式下运行,因此代码无法保存到用户请求的位置.

Since the process hosting my ActiveX is running in Internet Explorer's Protected mode, the code cannot save to the user's requested location.

相反,文件会以静默方式保存到用户未请求的位置.

Instead the files are silently saved to a location that the user did not request.

相反,文件会以静默方式保存到最终用户无法找到它们的位置.

Instead the files are silently saved to a location where the end-user is not able to find them.

对如何处理有什么建议吗?

Is there any suggestions of how to handle this?

用户要保存到硬盘的内容是什么?这个问题无关紧要.但假装:

What is the user trying to save to their hard drive? It doesn't matter to the question. But pretend:

  • 这是几百兆的3D cad网格
  • 这是GIS影像转储
  • 这是PDF
  • 这是PNG
  • 这是一个文本文件

Internet Explorer的保护模式api 确实允许外接程序显示保存的日志:

Internet Explorer's protected mode api does allow addins to show a savedialog:

IEShowSaveFileDialog(this.Handle, "Eden.3ds", 
      GetUserDocumentsFolder(), null, 
      "3D Studio File|*.3ds|GIS Imagery|*.kvm|Adobe Acrobat File|*.pdf|All Files|*.*|"
      null, 0, 
      OFN_ENABLESIZING | OFN_PATHMUSTEXIST,
      ref destinationPath, ref stateCookie);

,然后使用保存的提供的 cookie 保存文件:

and then save the file using that cookie that save provided:

IESaveFile(stateCookie, sourcefilename);

sourcefilename将会是我设法保存到某个地方的文件(这是另一个问题).

Where sourcefilename is going to be a file that i managed to save somewhere (which is another question).

了解并在保护模式下工作Internet Explorer

将文件保存到用户配置文件

Understanding and Working in Protected Mode Internet Explorer

Saving Files to the User Profile

某些扩展名需要将文件保存到特定位置,以便用户或应用程序以后可以找到文件.以下步骤显示了如何将文件保存在完整性较低的位置之外:

Some extensions need to save files to a particular location so that users or applications can later find the files. The following steps show how to save a file outside of a low integrity location:

在%userprofile%\ AppData \ LocalLow中创建文件的临时版本.成功保存文件后,请记住删除该临时文件.

Create a temporary version of the file in %userprofile%\AppData\LocalLow. Remember to delete the temporary file after the file is sucessfully saved.

致电 ,并显示用户个人资料文件夹的位置,以提示用户将文件保存在其他位置.如果用户接受另存为对话框,则 IEShowSaveFileDialog 将返回所选的目标文件夹.

Call IEShowSaveFileDialog with the location of the user's profile folder to prompt the user to save the file in a different location. If the user accepts the Save As dialog, IEShowSaveFileDialog returns the chosen destination folder.

致电 ,并保存在步骤1中保存的临时文件的位置.

Call IESaveFile with the location of the temporary file saved in Step 1.

执行此操作时,保护模式的用户代理将文件从临时位置复制到用户选择的位置.

When you do this, Protected Mode's user broker copies the file from the temporary location to the location selected by the user.

推荐答案

The Internet Explorer Protected Mode API is how an ActiveX can save a file outside the low privelage areas:

  1. 将文件保存到 FOLDERID_LocalAppDataLow 文件夹;允许在IE中以完整性级别运行的进程编写:

  1. Save your file to the FOLDERID_LocalAppDataLow folder; where processes running at Low integrity level in IE are allowed to write:

String sourceFile = SHGetKnownFolderPath(FOLDERID_LocalAppDataLow)+"\tempcopy.dat";
SaveToFile(sourceFile);

  • 使用 IEShowSaveFileDialog :

  • Show the user a save dialog using IEShowSaveFileDialog:

    int stateCookie = 0;
    
    IEShowSaveFileDialog(this.Handle, //hwnd
          "FemaleMesh.3ds", //suggested filename
          SHGetKnownFolder(FOLDERID_Desktop), //suggested save location
          "3D Studio Mesh|*.3ds|All Files|*.*", //save filer
          "3ds", //default extension
          1, //default one-based filter index
          ref destinationFile, 
          ref stateCookie);
    

  • 指示IE使用

  • Instruct IE to move our temporary file to the location the user selected using IESaveFile:

    IESaveFile(stateCookie, sourceFile);
    

  • 因此,我 是正确的,即IE保护模式API是要使用的API.我只需要翻译所有API标头,弄清楚导入,编写代码,调试,测试它,然后我就可以确定它 是要使用的正确API.

    So i was right that IE Protected Mode API was the API to use. i just had to translate all the API headers, figure out the imports, write the code, debug it, test it, before i could figure out that it is the correct API to use.

    注意:您可以通过调用

    Note: You can save yourself some work by checking if IE is running in protected mode first, by calling IEIsProtectedModeProcess:

    Boolean isProtectedMode = IEIsProtectedModeProcess();
    

    奖金Chat不休

    IE保护模式API 函数无法在Internet Explorer外部运行.

    Bonus Chatter

    The IE protected mode API functions do not work from outside Internet Explorer.

    注意:任何代码都已发布到公共领域.无需注明出处.

    Note: Any code is released into the public domain. No attribution required.

    这篇关于从ActiveX(保护模式IE)保存文件的技术的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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