c - 使用 ShellExecuteEx 在已启动的实例中调用 iexplore.exe

标签 c windows winapi sdk

我使用 ShellExecuteEx 调用 iexplore.exe,每当我启动应用程序时,都会创建一个新的 Internet Explorer 实例,无论 Internet Explorer 是否已经打开。

我想改变这一点,如果已经有一个 Internet Explorer 实例,我需要在该实例中打开一个新选项卡,其中包含我传递给 ShExecInfo.lpParameters 的地址,因此无需创建新窗口。有没有办法做到这一点?请指教..

更新: 在下面的回答中我遇到了一个问题,当我将 lpFile 参数设置为“iexplore.exe”并将 lpParameters 设置为“www.google.com”时,会打开两个窗口。如果我忽略 lpfile 参数,那么下面的代码会在某些机器上打开默认浏览器。我只想打开 Internet Explorer。请帮助..

int WINAPI WinMain ( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { 


 ShellExecute(0,L"open",L"iexplore.exe", L"http://www.google.com",0,SW_SHOWDEFAULT );       


 ShellExecute(0,L"open", L"iexplore.exe", L"http://www.yahoo.com",0,SW_SHOWDEFAULT );        

 return 0;

} 

最佳答案

它与 ShellExecute 配合使用。

#include <stdio.h>
#include <tchar.h>
#include <Windows.h>


int _tmain(int argc, _TCHAR* argv[])
{
    ShellExecute(0,L"open",L"http://www.google.com",0,0,SW_SHOWDEFAULT );   
    ShellExecute(0,L"open",L"http://www.yahoo.com",0,0,SW_SHOWDEFAULT );    
    return 0;
}

关于c - 使用 ShellExecuteEx 在已启动的实例中调用 iexplore.exe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12000876/

相关文章:

c - 命令行输入 '\0'字符怎么办?

c - 如何定义数据类型

c - 将数据设置到nodePtr而不覆盖

windows - 批处理脚本 - 等到网络建立

windows - 64 位 Windows 8.1 和 Qt 上的 MIDI 应用程序 - 指针大小问题

c++ - C++ 中的 Pause()、Sleep() 和 Wait() 有什么区别?

c - 嵌套宏调用

c++ - 在 C++ 中使用变量作为 system() 输入而不使用 c_str()

windows - 从 Git 推送和 pull 后,目录符号链接(symbolic link)更改为文件符号链接(symbolic link)

python-3.x - python3 ctype CreateWindowEx 简单示例