[英]How to modify context menu of internet explorer using IDocHostUIHandler::ShowContextMenu?
[英]How to add parameter to Internet Explorer using ShellExecute
我正在用C ++编写一个简单的控制台应用程序,它将Android平板电脑与PC连接起来。
为此,我必须在Internet Explorer中键入“ \\\\ 192.168.1.5”(在其他任何地方都无法使用)。 所以我想写一个简单的应用程序代替我。 但是Internet Explorer不想除了以\\\\开头的参数。
此代码与打开网页完美配合,但不能解决我的问题。
#include "stdafx.h"
#include "Windows.h"
int _tmain(int argc, _TCHAR* argv[]){
LPCTSTR open = L"open";
LPCTSTR file = L"iexplore.exe";
LPCTSTR path = L"C:\Program Files\Internet Explorer";
LPCTSTR parameters = L"\\192.168.1.5";
ShellExecute(NULL, open, file, parameters, path, SW_SHOWNORMAL);
return 0;
}
您能提出解决方案吗?
不要忘记您的转义序列:)
LPCTSTR path = L"C:\Program Files\Internet Explorer";
应该
LPCTSTR path = L"C:\\Program Files\\Internet Explorer\\";
下面是您想做的工作示例:(使用C ++ String对象)。
String strAction = "open";
String strURL = "http://192.168.1.5";
String strFile = "iexplore.exe";
String strPath = "C:\\Program Files\\Internet Explorer\\";
ShellExecute(NULL, strAction.c_str(), strFile.c_str(), strURL.c_str(), strPath.c_str(), SW_SHOWNORMAL);
如果您只想在默认浏览器中打开网址,则可以执行以下操作:
String strAction = "open";
String strURL = "http://192.168.1.5";
ShellExecute(NULL, strAction.c_str(), strURL.c_str(), NULL, NULL, SW_SHOWNORMAL);
使用下面的代码在Windows文件资源管理器中打开您的URL。 确保保留目录参数NULL
。
String strAction = "open";
String strURL = "file:\\\\192.168.1.5";
String strFile = "explorer.exe";
ShellExecute(NULL, strAction.c_str(), strFile.c_str(), strURL.c_str(), NULL, SW_SHOWNORMAL);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.