ShellExecute的强大功能

    技术2022-05-19  24

    #include "stdafx.h" #include <Windows.h> #include <tchar.h> #include <assert.h> #include <Shellapi.h> const TCHAR szOpertion[] = _T("open"); //const TCHAR szAddress[] = _T("www.265.com"); //const TCHAR szAddress[] = _T("c://"); const TCHAR szAddress[] = _T("c://1.log");

    int APIENTRY WinMain(HINSTANCE hInstance,                      HINSTANCE hPrevInstance,                      LPSTR     lpCmdLine,                      int       nCmdShow) {      // TODO: Place code here.     HINSTANCE hInst = ShellExecute(NULL, szOpertion, szAddress, NULL, NULL, SW_SHOWNORMAL);     assert(hInst > (HINSTANCE)32);     return 0; }

     

    若为网址,ShellExecute可以直接在浏览器打开此地址(浏览器会用默认浏览器,不一定是IE)

    若为盘符目录,则直接打开本地磁盘

    若为文件,则直接打开文件


    最新回复(0)