NO

Author Topic: Howto make a mini web browser using shdocvw.dll  (Read 5208 times)

koala

  • Guest
Howto make a mini web browser using shdocvw.dll
« on: October 16, 2007, 04:11:45 PM »

Somebody has tried to make a mini web browser using COM Object - Microsoft Web explorer (shdocvw.dll)?

whith .NET is simple, but i will do whith win32 api calls only.

I see some examples using other COM objects, but whithout graphical interface, like this:

int WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow)
{
    VARIANT root[64] = {0};  // Generic IDispatchs
    VARIANT parm[64] = {0};  // Generic Parameters
    VARIANT rVal = {0};  // Temporary result holder
    int level = 0;  // Current index into root[]

    // Initialize the OLE Library...
    OleInitialize(NULL);

    // VB: Dim OlApp As Object
    VARIANT OlApp = {0};

    // VB: Set OlApp = CreateObject Outlook.Application
    {
        CLSID clsid;
        CLSIDFromProgID(L"Outlook.Application", &clsid);
        HRESULT hr = CoCreateInstance(&clsid, NULL, CLSCTX_LOCAL_SERVER|CLSCTX_INPROC_SERVER, &IID_IDispatch, (void **)&rVal.pdispVal);
        if(FAILED(hr))
           {
            char buf[256];
            sprintf(buf, "CoCreateInstance() for \"Outlook.Application\" failed. Err=%08lx", hr);
            MessageBox(NULL, buf, "Error", MB_SETFOREGROUND|MB_ICONHAND);
            return 1;
           }
        rVal.vt = VT_DISPATCH;
    }
    VariantCopy(&OlApp, &rVal);
    VariantClear(&rVal);

    // VB: Dim OlMail As Object
    VARIANT OlMail = {0};

    // VB: Set OlMail = OlApp.CreateItem(olMailItem)
    VariantCopy(&root[++level], &OlApp);
    parm[0].vt = VT_I4; parm[0].lVal = 0;
    AutoWrap(DISPATCH_PROPERTYGET|DISPATCH_METHOD, &rVal, root[level].pdispVal, L"CreateItem", 1,parm[0]);
    VariantClear(&parm[0]);
    VariantClear(&root[level--]);
    VariantCopy(&OlMail, &rVal);
    VariantClear(&rVal);
    [...] etc...

-----------------------------

Sorry for my poor english.

Thank you.