如何在项目资源中存储Hta/HTML文件并在程序中使用 [英] How to Store Hta/Html File in Project Resources and Use in Program

查看:163
本文介绍了如何在项目资源中存储Hta/HTML文件并在程序中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将.hta文件添加到我的应用程序的资源中,如下所示:

I have added an .hta file to my applciation's resources like so:

我想使用以下行显示此内容:

And I would like to display this by using the line:

Process.Start("explorer.exe", @"Path\To\File.hta");

当文件在我的系统上时有效,但是当我尝试使用以下命令显示.hta时:

This works when the file is on my system, but when I try displaying the .hta with:

Process.Start("explorer.exe", Properties.Resources.htatest);

我看到此错误:

没有关联的程序可以执行请求的操作.请安装一个程序,或者如果已经安装了一个程序,则在默认程序"控制面板中创建一个关联.

There is no program associated to perform the requested action. Please install a program or, if one is already installed, create an association in the Default Programs control panel.

是否可以在项目资源中存储.hta,然后从程序中调用它?

Is it possible to store an .hta in my project resources and then call it from the Program?

作为参考,这是.hta内部的代码:

For reference, here is the code which exists inside the .hta:

<html>
    <head>
        <title>IT Support - Message</title>
    </head>
    <script language = "VBScript">
        window.setInterval "setfocus()", 100
        Function setfocus
            window.focus()
        End Function
    </script>

    <body>
        <div style="margin-top:10%;">
            <h1 style="font-family:Segoe UI; color:#AF2B71; text-align: center; margin-top: 100pt">Message Heading</h1>
            <p style="font-family:Segoe UI; text-align: center"><strong/>This is a message which will be displayed to the user. </p>    
        </div>
    </body>
</html>

推荐答案

如注释中所述,必须将其添加为项目资源,然后复制到输出目录中.

As mentioned in the comments, this will have to be added as a project resource and then copied into the output directory.

Explorer无法提取嵌入到可执行文件中的文件.

Explorer has no way of extracting files which have been embedded into an executable.

这篇关于如何在项目资源中存储Hta/HTML文件并在程序中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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