vba 通过 VB 将命令行参数传递给 Internet Explorer
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/171452/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Passing Command Line Arguments to internet explorer via VB
提问by Julien Dumoulin
I've got an app that my client wants to open a kiosk window to ie on startup that goes to their corporate internet. Vb isn't my thing but they wanted it integrated into their current program and I figured it would be easy so I've got
我有一个应用程序,我的客户想要打开一个信息亭窗口,即在启动时进入他们的公司互联网。Vb 不是我的东西,但他们希望将它集成到他们当前的程序中,我认为这很容易,所以我有
Shell ("explorer.exe http://www.corporateintranet.com")
and command line thing that needs to be passed is -k
需要传递的命令行内容是 -k
Can't figure out where in the hell to drop this to make it work. Thanks in advance! :)
无法弄清楚到底该把它放在哪里才能让它工作。提前致谢!:)
回答by Greg Hewgill
If you would like to use -k, you will probably want to call iexplore.exe
instead of explorer.exe
.
如果您想使用 -k,您可能需要调用iexplore.exe
而不是explorer.exe
.
回答by Greg Hewgill
This worked for me, not the most elegant but it'll do:
这对我有用,不是最优雅的,但它会做:
Shell ("C:\Program Files\Internet Explorer\iexplore.exe -k http://www.corporateintranet.com")
回答by Frank
You have it right now but I think you are missing the closing quote after iexplore.exe
您现在拥有它,但我认为您缺少 iexplore.exe 之后的结束语
You may also want to take out the [space]-k, set the zoom level to what will work for you in kiosk mode and then put the [space]-k back in. I am guessing there is a parameter or argument as they call it to pass the opening zoom level to iexplore but don't know how to do that yet.
您可能还想取出 [space]-k,将缩放级别设置为在 kiosk 模式下适合您的级别,然后将 [space]-k 放回去。我猜有一个参数或参数,因为它们调用它以将打开的缩放级别传递给 iexplore,但还不知道该怎么做。
回答by Julien Dumoulin
It's a bit late. But for whoever comes to this topic in the future, here is my suggestion: use the ShellExecute Function from the Shell32.dll
有点晚了。但是对于以后讨论这个话题的人,我的建议是:使用 Shell32.dll 中的 ShellExecute 函数
Example:
例子:
ShellExecute(Application.hwnd, "open", "http://www.corporateintranet.com", vbNullString, vbNullString, SW_SHOWNORMAL)
Here is the declaration to put in a module:
这是放入模块的声明:
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Public Const SW_SHOW = 5
Public Const SW_SHOWDEFAULT = 10
Public Const SW_SHOWNORMAL = 1