zoukankan      html  css  js  c++  java
  • ShellExecute

    ShellExecute

    Performs an operation on a specified file.

    HINSTANCE ShellExecute(

        HWND hwnd, 

        LPCTSTR lpVerb,

        LPCTSTR lpFile, 

        LPCTSTR lpParameters, 

        LPCTSTR lpDirectory,

        INT nShowCmd

    );

            

    ID

    lpVerb

    Description

    1. 

    edit

    Launches an editor and opens the document for editing. If lpFile is not a document file, the function will fail.

    2. 

    explore

    Explores the folder specified by lpFile.

    3. 

    find

    Initiates a search starting from the specified directory.

    4. 

    open

    Opens the file specified by the lpFile parameter. The file can be an executable file, a document file, or a folder.

    5. 

    print

    Prints the document file specified by lpFile. If lpFile is not a document file, the function will fail.

    6. 

    properties

    Displays the file or folder's properties.

    .

    关键点

    .

    实现过程

    .

    //打开记事本
    ShellExecute(NULL,"open","notepad.exe",NULL,NULL,SW_SHOW);
     
    //用记事本打开 C:\1.txt文件
    ShellExecute(NULL,"open","notepad.exe","C:\\1.txt",NULL,SW_SHOW);
     
    //用IE打开网页,如果你的默认浏览器不是IE,此方法非常有用
    ShellExecute(NULL,"open","iexplore.exe","www.baidu.com",NULL,SW_SHOW);
     
    //打开完美世界
    CString str="D:\\Administrator\\Documents\\Games\\WMSJ\\WMSJ_Client\\element\\elementclient.exe";
    ::SetCurrentDirectory(str.Left(str.ReverseFind('\\')));
    ShellExecute(NULL,NULL,str,"game:cpw",NULL,SW_SHOW); 
        
    //打开 C:\1.txt文件的属性对话框
        SHELLEXECUTEINFO SHELL ={0};
        SHELL.cbSize = sizeof(SHELLEXECUTEINFO);
        SHELL.fMask = SEE_MASK_INVOKEIDLIST ;
    //    SHELL.hwnd = NULL;
        SHELL.lpVerb = "properties";
        SHELL.lpFile = "c:\\1.txt";  
    //    SHELL.lpParameters = "";
    //    SHELL.lpDirectory = NULL;
        SHELL.nShow = SW_SHOW;
    //    SHELL.hInstApp = NULL ;
        ShellExecuteEx(&SHELL);     
      
     
     
     
    //如何启动一个程序,直到它运行结束?
        SHELLEXECUTEINFO ShellInfo;
        memset(&ShellInfo0, sizeof(ShellInfo));    
        ShellInfo.cbSize = sizeof(ShellInfo);    
        ShellInfo.hwnd = NULL;    
        ShellInfo.lpVerb = _T("open");
        ShellInfo.lpFile = "C:\\Windows\\System32\\cmd.exe";    
        ShellInfo.nShow = SW_SHOWNORMAL;
        ShellInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
        ShellExecuteEx(&ShellInfo);
        WaitForSingleObject(ShellInfo.hProcess,INFINITE);
     
    //定位文件在文件夹的位置  打开文件夹并选中这个文件

    ShellExecute(m_hWnd,NULL,"explorer.exe","e/,/select, C:\\Windows\\System32\\cmd.exe",NULL,SW_SHOWNORMAL);

    .

     

    .

    .

    备注

    .http://www.cppblog.com/SpringSnow/archive/2009/04/22/80719.html

    http://www.xuedelphi.cn/wenzhang/mrjq/jyjq/2008/10/200810032552.htm

     

    .关键点

    .

    相关链接

    相关链接 相关链接

    .




  • 相关阅读:
    win7下的vxworks总结
    ubuntu 无法获得锁 /var/lib/dpkg/lock
    项目中用到了的一些批处理文件
    win7下安装 WINDRIVER.TORNADO.V2.2.FOR.ARM
    使用opencv统计视频库的总时长
    January 05th, 2018 Week 01st Friday
    January 04th, 2018 Week 01st Thursday
    January 03rd, 2018 Week 01st Wednesday
    January 02nd, 2018 Week 01st Tuesday
    January 01st, 2018 Week 01st Monday
  • 原文地址:https://www.cnblogs.com/xe2011/p/2923679.html
Copyright © 2011-2022 走看看