ShellExecuteEx 函数 和 URLDownloadToFile 函数

1、使用 ShellExecuteEx 函数以 Windows 系统自带的 IE 浏览器,打开VC驿站的网址:https://www.cctry.com/
2、使用 ShellExecuteEx 函数打开 C:\Windows\System32 目录,并选中 cmd.exe 这个文件;
3、使用 ShellExecuteEx 函数打开 我的电脑/此电脑;
4、使用 ShellExecuteEx 函数打开 C:\Windows 目录的文件属性对话框。

#include <Windows.h>
#include <tchar.h>
#pragma comment(lib, "urlmon.lib")
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPreInstance, LPTSTR lpCmdLine, INT nCmdShow)
{

    //1、使用 ShellExecuteEx 函数以 Windows 系统自带的 IE 浏览器,
    //打开VC驿站的网址:https ://www.cctry.com/;

    /*SHELLEXECUTEINFO Shell_Info = { 0 };
    Shell_Info.cbSize = sizeof(SHELLEXECUTEINFO);
    Shell_Info.lpFile = _T("C:\\Program Files\\Internet Explorer\\iexplore.exe");
    Shell_Info.lpParameters = _T("https://www.cctry.com/");
    Shell_Info.nShow = SW_SHOWNORMAL;
    Shell_Info.lpVerb = _T("open");
    ShellExecuteEx(&Shell_Info);*/

    //2、使用 ShellExecuteEx 函数打开 C : \Windows\System32 目录,并选中 cmd.exe 这个文件;

    //SHELLEXECUTEINFO Shell_cmd = { 0 };
    //Shell_cmd.cbSize = sizeof(SHELLEXECUTEINFO);
    //Shell_cmd.lpFile = _T("explorer.exe");
    //Shell_cmd.lpParameters = _T("/select,C:\\Windows\\System32\\cmd.exe");
    //Shell_cmd.lpVerb = _T("open");
    //Shell_cmd.nShow = SW_SHOWNORMAL;
    //ShellExecuteEx(&Shell_cmd);

    //3、使用 ShellExecuteEx 函数打开 我的电脑 / 此电脑;

    //SHELLEXECUTEINFO Shell_my = { 0 };
    //Shell_my.cbSize = sizeof(SHELLEXECUTEINFO);
    //Shell_my.lpFile = _T("explorer");
    //Shell_my.lpParameters = _T("::{20d04fe0-3aea-1069-a2d8-08002b30309d}");
    //Shell_my.lpVerb = _T("open");
    //Shell_my.nShow = SW_SHOW;
    //Shell_my.fMask = SEE_MASK_INVOKEIDLIST;
    //ShellExecuteEx(&Shell_my);

    //4、使用 ShellExecuteEx 函数打开 C : \Windows 目录的文件属性对话框。

    //SHELLEXECUTEINFO ShellInfo = { 0 };
    //ShellInfo.cbSize = sizeof(SHELLEXECUTEINFO);
    //ShellInfo.lpVerb = _T("properties");
    //ShellInfo.lpFile = _T("C:\\Windows");
    //ShellInfo.fMask = SEE_MASK_INVOKEIDLIST;
    //ShellInfo.nShow = SW_SHOWNORMAL;
    //BOOL bRet = ShellExecuteEx(&ShellInfo);

    HRESULT hRet = URLDownloadToFile(NULL, _T("https://www.baidu.com/img/flexible/logo/pc/result.png"),_T("D:\\1.png"), 0, NULL);
    return 0;
}

 

posted on 2021-01-18 16:40  SakuraQAQ  阅读(245)  评论(0)    收藏  举报

导航