简体   繁体   English

如何在CD / DVD上自动打开html页面

[英]How to make an html page open automatically on a CD/DVD

I need to include an html page (table of contents) on a CD/DVD. 我需要在CD / DVD上包含一个html页面(目录)。 I'd like the html page to open automatically when the user puts the CD/DVD in their machine. 当用户将CD / DVD放入他们的机器时,我希望自动打开html页面。 Is there a way to do this (the MSDN cds do this) either by purchasing software or otherwise? 有没有办法通过购买软件或其他方式(MSDN cds这样做)?

You should be able to do with a relatively simple autorun.inf file in the CD/DVD's root directory: 您应该可以使用CD / DVD根目录中相对简单的autorun.inf文件:

[autorun]
shellexecute=path\to\htmlfile.html

I used (the free version of) AutoRunPro 我使用(免费版) AutoRunPro

I remember when I was confronted with the problem once 我记得曾经遇到过这个问题的时候

[autorun]
shellexecute=path\to\htmlfile.html

just wouldn't work on most PC's. 只是不适用于大多数PC。 I used a program called AutorunPro.EXE, just copied it in the root, and the autorun.inf was : 我使用了一个名为AutorunPro.EXE的程序,只是将它复制到根目录中,而autorun.inf是:

[Autorun]
open=AutoRunPro.exe

[AutorunPro]
; Here are some sample uses for Autorunpro. It keeps processing Them in Run1..RunN         order until it doesnt find one.
Run1=index.htm
Run2=.

Moreover, you can open several programs, pages, ... with this method in one go. 此外,您可以一次性使用此方法打开多个程序,页面....

In either case : test your method beforehand, you don't actually have to burn a CD/DVD in order to do that : look here 在任何一种情况下:事先测试你的方法,你实际上不需要刻录CD / DVD来做到这一点: 看这里

If you don't want to trust to third party programs, or skip over them entirely you can read the MSDN AutoRun Reference . 如果您不想信任第三方程序,或完全跳过它们,则可以阅读MSDN AutoRun参考 It's not too bad. 这不是太糟糕。

ShelExec is your ticket. ShelExec是您的机票。 It is free and allows you to specify an optional ico file too. 它是免费的,允许您指定可选的ico文件。

You can create simple executable yourself. 您可以自己创建简单的可执行文 In Visual Studio in example. 在Visual Studio中的示例。

Not sure it can be call one-liner but it is not far from it :-) 不确定它可以叫一线,但它离它不远:-)

#include "stdafx.h"
#include "windows.h"
#include "Shellapi.h"

int main(int argc, char* argv[])
{
    ::ShellExecute(NULL, "open", "path\to\htmlfile.html", 0, 0, SW_NORMAL);
    return 0;
}

To avoid hard-coding you can try passing path as a parameter in command line. 为避免硬编码,您可以尝试在路径中将路径作为参数传递。

autorun file must be added to the CD. 必须将自动运行文件添加到CD。 File can look like this. 文件可能如下所示。

[autorun]
icon=\MySexyIcon.ico
label=MySuperCD
open=YourExecutable.exe

Please bear in mind that it will not work on iOS though. 请记住,它不适用于iOS。

It's dead simple. 这很简单。 I use a program called Autorun Pro. 我使用一个名为Autorun Pro的程序。 Check out this guide . 查看本指南

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM