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;
}

Powered by Jekyll and Theme by solid

本站总访问量