Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. error C2664:'load':cannot convert parameter 1 from 'unsigned short *' to 'struct tagVARIANT'

error C2664:'load':cannot convert parameter 1 from 'unsigned short *' to 'struct tagVARIANT'

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    CHYGO
    wrote on last edited by
    #1

    IXMLDOMDocument *pDoc = NULL; BSTR bstr = NULL; ... bstr = filename.AllocSysString(); hr = pDoc->load (bstr, b_load); filename is a CString type,how can i slove this problem?

    i 've tried ,then i have no regret

    N 1 Reply Last reply
    0
    • C CHYGO

      IXMLDOMDocument *pDoc = NULL; BSTR bstr = NULL; ... bstr = filename.AllocSysString(); hr = pDoc->load (bstr, b_load); filename is a CString type,how can i slove this problem?

      i 've tried ,then i have no regret

      N Offline
      N Offline
      norish
      wrote on last edited by
      #2

      The load's prototype is below, this is the reason.

          virtual /\* \[helpstring\]\[id\] \*/ HRESULT STDMETHODCALLTYPE load( 
              /\* \[in\] \*/ VARIANT xmlSource,
              /\* \[retval\]\[out\] \*/ VARIANT\_BOOL \*isSuccessful) = 0;
      

      One solution is this.

      #include <comdef.h>
      ...
      bstr = filename.AllocSysString();
      _variant_t file(bstr);
      hr = pDoc->load (file, b_load);

      _ 1 Reply Last reply
      0
      • N norish

        The load's prototype is below, this is the reason.

            virtual /\* \[helpstring\]\[id\] \*/ HRESULT STDMETHODCALLTYPE load( 
                /\* \[in\] \*/ VARIANT xmlSource,
                /\* \[retval\]\[out\] \*/ VARIANT\_BOOL \*isSuccessful) = 0;
        

        One solution is this.

        #include <comdef.h>
        ...
        bstr = filename.AllocSysString();
        _variant_t file(bstr);
        hr = pDoc->load (file, b_load);

        _ Offline
        _ Offline
        _Superman_
        wrote on last edited by
        #3

        Or you can use the ATL class CComVariant in a similar way.

        CComVariant file(filename);
        CComVariant success(false);
        hr = pDoc->load(file, &success);

        «_Superman_» I love work. It gives me something to do between weekends.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups