2010年1月27日 星期三

CuShellExecuteEx - Performs an operation on a specified file.

// Performs an operation on a specified file.



// CuShellExecuteEx.h

class CuShellExecuteEx  
{

public:
    void SetExecuteFile(wstring strFile, BOOL bAutoModuleFile = FALSE);
    BOOL OnShellExecuteEx();

    SHELLEXECUTEINFO m_sei;
    wstring m_strExecuteFile;

    CuShellExecuteEx();
    ~CuShellExecuteEx();

};


// CuShellExecuteEx.cpp

CuShellExecuteEx::CuShellExecuteEx()
{
    m_sei.cbSize = sizeof(SHELLEXECUTEINFO);
    m_sei.fMask = 0;
    m_sei.hwnd = NULL;
    m_sei.lpVerb = TEXT("open");
    m_sei.lpFile = NULL;
    m_sei.lpParameters = NULL;
    m_sei.lpDirectory = NULL;
    m_sei.nShow = SW_SHOW;
    m_sei.hInstApp = NULL;
}

CuShellExecuteEx::~CuShellExecuteEx()
{

}

BOOL CuShellExecuteEx::OnShellExecuteEx()
{
    return ::ShellExecuteEx(&m_sei);
}

void CuShellExecuteEx::SetExecuteFile(wstring strFile, BOOL bAutoModuleFile /*= FALSE*/)
{

    if( bAutoModuleFile )
    {
        CuModuleFile mf;
        strFile = mf.GetModuleFileName(strFile);
    }

    m_strExecuteFile = strFile;
    m_sei.lpFile = m_strExecuteFile.c_str();

}

1 則留言:

  1. 這個東西跟Command 範式沒有任何關係! 好吧, 我說了個謊, 基本上的觀點是, 延後執行, 若是包含這個條件,明顯的是打算做command.

    回覆刪除