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;
}
原文地址:https://www.cnblogs.com/cutepig/p/1957010.html