从浏览器启动应用程序 - Application URL
2016-01-03 11:51
381 查看
关键字:Browser,Application,URL Protocol,Windows,Mac,IE,Chrome,Safari。
OS: Windows 7, OS X Yosemite。
2.在windows上新建文件MyApp.reg,文件内容如下:
注:把"L:\\Dev\\MyApp\\Debug\\MyApp.exe\"更新为MyApp.exe所在的路径。
在Windows上运行MyApp.reg添加内容到注册表,如下图:
4.写一段HTML测试代码如下,保存到文件MyAppTest.html:
分别在Windows上用浏览器运行MyAppTest.html,点击“Open in MyApp”,结果如下:
1.选择你的 project.
2.选择你的 target.
3.打开 Info tab.
4.在URL Types下面添加新的URL.
如下图:
在Safari里面运行URL:myapp://,将启动这个应用。
OS: Windows 7, OS X Yosemite。
Windows:
1.写一个C++ 应用程序,代码如下:#include <iostream> #include <string> using namespace std; int main(int argc, char* argv[]) { if(argc > 1) { std::string argi(argv[1]); cout<<argi<<endl; } cout<<"Press any key to continue"<<endl; int i; cin>>i; return 0; }
2.在windows上新建文件MyApp.reg,文件内容如下:
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\MyApp] @="Open MyApp" "URL Protocol"="" [HKEY_CLASSES_ROOT\MyApp\shell] [HKEY_CLASSES_ROOT\MyApp\shell\open] [HKEY_CLASSES_ROOT\MyApp\shell\open\command] @="\"L:\\Dev\\MyApp\\Debug\\MyApp.exe\" \"%1\""
注:把"L:\\Dev\\MyApp\\Debug\\MyApp.exe\"更新为MyApp.exe所在的路径。
在Windows上运行MyApp.reg添加内容到注册表,如下图:
4.写一段HTML测试代码如下,保存到文件MyAppTest.html:
<!DOCTYPE html> <html> <body> file URL or path: <input id='fileinput' type='text'/><br> <button type='button' onclick='window.location.href = "MyApp://command=open&file=" + encodeURIComponent(document.getElementById("fileinput").value)'>Open in MyApp</button> <button type='button' onclick='window.location.href = "MyApp://command=insert&file=" + encodeURIComponent(document.getElementById("fileinput").value)'>Insert in MyApp</button> </body> </html>
分别在Windows上用浏览器运行MyAppTest.html,点击“Open in MyApp”,结果如下:
OSX:
用Xode打开你的project1.选择你的 project.
2.选择你的 target.
3.打开 Info tab.
4.在URL Types下面添加新的URL.
如下图:
在Safari里面运行URL:myapp://,将启动这个应用。
相关文章推荐
- Swift -- 方法
- Cocos2dx 3.x创建Layer的步骤
- 关于iOS默认中文输入法乱码的Bug解决记录
- 基于IOS上MDM技术相关资料整理及汇总
- 怎么样在iOS开发中用ARC和MRC混编
- Android获取WiFi IP地址
- iOS微信支付SDK开发经验
- Android开发学习之路-Service和Activity的通信
- iOS 关于屏幕旋转shouldAutorotate
- iOS之block
- Android 百度地图经纬度转换成地址
- Android 4.4(API 19)闹钟管理与计步器功能
- iOS 单元測试之XCTest具体解释(一)
- CALayer - 10
- 关于 android ImageView 圆角处理 圆图
- Unity中使用ulua的个人经验总结
- Gradle for Android 第三篇( 依赖管理 )
- objectarx开发的环境设置
- Android访问权限详解
- Unity-Animator深入系列---目标匹配Target Matching