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

     

    .关键点

    .

    相关链接

    相关链接 相关链接

    .




  • 相关阅读:
    php发送post请求的方法
    跨域请求的三种解决办法
    php验证码+js点击刷新
    13.mysql数据类型
    12.dateformat常用格式
    11.设计的三大范式
    nginx passwd (http://www.voidcn.com/article/p-suebfyqy-nx.html)
    删除文件 过滤某个文件
    mac必装软件
    elasticsearch 安装
  • 原文地址:https://www.cnblogs.com/xe2011/p/2923679.html
Copyright © 2011-2022 走看看