您的位置:首页 > 其它

通过URL启动应用程序

2016-12-22 13:29 106 查看
html

<a href="myApp://Hello!">点击这里启动程序</a>


reg.reg

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\myApp]
@="myAppProtocol"
"URL Protocol"="C:\\Program Files (x86)\\MyApp\\MyApp.exe"

[HKEY_CLASSES_ROOT\myApp\DefaultIcon]
@="C:\\Program Files (x86)\\MyApp\MyApp.exe"

[HKEY_CLASSES_ROOT\myApp\shell]
@="open"

[HKEY_CLASSES_ROOT\myApp\shell\open]
@="open"

[HKEY_CLASSES_ROOT\myApp\shell\open\command]
@="\"C:\\Program Files (x86)\\MyApp\\MyApp.exe\" \"%1\""


QSetting写入注册表

#define APP_NAME        "MyApp"
#define RUN_EXE         "MyApp.exe"
#define REGEDIT_URL     "HKEY_CLASSES_ROOT\\"
QString installPath = "C:\\Program Files (x86)\\MyApp"

//<a href="heyad://Hello!">点击这里启动程序</a>
{
QSettings *regProtocol = new QSettings(QString(REGEDIT_URL) + APP_NAME, QSettings::NativeFormat);///写入URL启动协议至注册表
regProtocol->setValue(".","heyadProtocol");
regProtocol->setValue("URL Protocol", installPath + "\\" + RUN_EXE);
delete regProtocol;
}
{
QSettings *regProtocol = new QSettings(QString(REGEDIT_URL) + APP_NAME + "\\DefaultIcon", QSettings::NativeFormat);
regProtocol->setValue(".", "");
delete regProtocol;
}
{
QSettings * regProtocol = new QSettings(QString(REGEDIT_URL) + APP_NAME + "\\shell", QSettings::NativeFormat);
regProtocol->setValue(".", "open");
delete regProtocol;
}
{
QSettings* regProtocol = new QSettings(QString(REGEDIT_URL) + APP_NAME + "\\shell\\open", QSettings::NativeFormat);
regProtocol->setValue(".", "open");
delete regProtocol;
}
{
QSettings* regProtocol = new QSettings(QString(REGEDIT_URL) + APP_NAME + "\\shell\\open\\command", QSettings::NativeFormat);   ///写入URL启动协议至注册表
regProtocol->setValue(".", QString("\"") + installPath + "\\" + RUN_EXE + "\" \"%1\"");
delete regProtocol;
}


注意: . 就是(默认)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐