我用向导生成了一个对话框程序,然后在里面加一个按钮,在按下这个按钮的时候,
调用一个exe文件,请问这个命令是什么?
谢谢帮助!

解决方案 »

  1.   

    WinExec( "cmd.exe /c winmine.exe",SW_SHOW);  可以ShellExecute(handle, "open", path_to_folder, NULL, NULL, SW_SHOWNORMAL);也可以
      

  2.   

    按下按钮会有buttonclick事件,对应函数OnClick(),在函数里调用WinExec()。
      

  3.   

    //执行外部程序,打开文件
    // nShowCmd = SW_HIDE,SW_MAXIMIZE,SW_MINIMIZE,SW_RESTORE,SW_SHOW,SW_SHOWNORMAL
    //            Default is : SW_SHOWNORMAL
    // strPrgName 文件名
    BOOL ExecutePrg(LPCTSTR strPrgName,int nShowCmd)
    {
    HINSTANCE bResult = 0 ;
    bResult = ::ShellExecute(NULL,"OPEN",strPrgName,NULL,"\\.",nShowCmd) ; if( bResult < (HINSTANCE)32)
    return FALSE ;
    else
    return TRUE ;
    }
    做过关联的就可以直接 open
    在 Click 事件中输入
    ExecutePrg(程序名,要显示的状态):
      

  4.   

    这里找不到答案吗?来这里试试看!
    这里有问必答
    http://systemer.51.net/cgi-bin/leoboard.cgi
    希望你能在这里找到你满意的答案
      

  5.   

    WinExec()
    ShellExcute()都可以。
      

  6.   

    一条命令调用外部程序
    PROCESS_INFORMATION pi;
        STARTUPINFO si;
        si.cb = sizeof(STARTUPINFO);
        si.lpReserved = NULL;
        si.lpDesktop = NULL;
        si.lpTitle = NULL;
        si.dwFlags = 0;
       si.cbReserved2 = 0;
        si.lpReserved2 = NULL;
        DWORD dwRes = 0;
        if(CreateProcess("c:\\windows\\Notepad.exe",NULL,NULL,NULL,false,CREATE_NEW_CONSOLE|NORMAL_PRIORITY_CLASS,NULL,NULL,&si,&pi))
    {
        //作其它操作。
    }
        else
    {
            dwRes = GetLastError();
       ShowMessage("excute over");
    }
      

  7.   

    void CTempDlg::OnButton1() 
    {
    // TODO: Add your control notification handler code here
    WinExec("c:\winnt\system32\vfp6run.exe", SW_SHOW);
    }
    这是我得代码,请问为什么出错?
    --------------------Configuration: temp - Win32 Debug--------------------
    Compiling...
    tempDlg.cpp
    E:\vc\temp\tempDlg.cpp(99) : warning C4129: 'w' : unrecognized character escape sequence
    E:\vc\temp\tempDlg.cpp(99) : warning C4129: 's' : unrecognized character escape sequence
    Linking...temp.exe - 0 error(s), 2 warning(s)
      

  8.   

    void CTempDlg::OnButton1() 
    {
    // TODO: Add your control notification handler code here
    WinExec("c:\\winnt\\system32\\vfp6run.exe", SW_SHOW);
    }
    谢谢,这样就可以了!
      

  9.   

    //执行外部程序,打开文件
    // nShowCmd = SW_HIDE,SW_MAXIMIZE,SW_MINIMIZE,SW_RESTORE,SW_SHOW,SW_SHOWNORMAL
    //            Default is : SW_SHOWNORMAL
    // strPrgName 文件名
    BOOL ExecutePrg(LPCTSTR strPrgName,int nShowCmd)
    {
    HINSTANCE bResult = 0 ;
    bResult = ::ShellExecute(NULL,"OPEN",strPrgName,NULL,"\\.",nShowCmd) ; if( bResult < (HINSTANCE)32)
    return FALSE ;
    else
    return TRUE ;
    }在 Click 事件中输入
    ExecutePrg(("c:\\winnt\\system32\\vfp6run.exe", SW_SHOW);
    ExecutePrg(("hello.txt", SW_SHOW);
    ExecutePrg((".........", SW_SHOW);
      

  10.   

    ShellExecute(NULL, NULL,"ExecSystem.exe", NULL, NULL, SW_SHOWNORMAL);