Atl: COM IDispatch interface client

#include <atlstr.h>        //CString

int _tmain(int argc, _TCHAR* argv[])
{
    CoInitialize(NULL);

    CComPtr<IDispatch> m_pFSO;
    
    CComVariant strFolder(_T("C:\\11111") );
    LPCOLESTR lpszName = L"CreateFolder";

    m_pFSO.CoCreateInstance ( L"Scripting.FileSystemObject" );

#if 1
    HRESULT hRes = m_pFSO.Invoke1(lpszName, &strFolder);
#else
    DISPID dispid;
    HRESULT hr = m_pFSO.GetIDOfName(lpszName, &dispid);

    HRESULT hRes = m_pFSO.Invoke1(dispid, &strFolder);
#endif

    return 0;
}

posted on 2011-02-17 15:19  cutepig  阅读(304)  评论(0编辑  收藏  举报

导航