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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to check CComVariant.boolval is valid and extract bool value from it

How to check CComVariant.boolval is valid and extract bool value from it

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorial
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.
  • P Offline
    P Offline
    ptr_Electron
    wrote on last edited by
    #1

    I want ot check CComVariant.boolval is valid and extract bool value from it

    if(SUCCEEDED(m_abc->GetProperty("test", comVar)))
    {
    if (comVar.boolVal == VARIANT_TRUE)
    {
    //should enter if true and valid, but enters if invalid case as well
    }
    }

    please help!

    B J 2 Replies Last reply
    0
    • P ptr_Electron

      I want ot check CComVariant.boolval is valid and extract bool value from it

      if(SUCCEEDED(m_abc->GetProperty("test", comVar)))
      {
      if (comVar.boolVal == VARIANT_TRUE)
      {
      //should enter if true and valid, but enters if invalid case as well
      }
      }

      please help!

      B Offline
      B Offline
      bjorn_ht
      wrote on last edited by
      #2

      It could be that m_abc->GetProperty returns something other than a bool, so you should also check comVar.vt to see that you really have a boolean.

      1 Reply Last reply
      0
      • P ptr_Electron

        I want ot check CComVariant.boolval is valid and extract bool value from it

        if(SUCCEEDED(m_abc->GetProperty("test", comVar)))
        {
        if (comVar.boolVal == VARIANT_TRUE)
        {
        //should enter if true and valid, but enters if invalid case as well
        }
        }

        please help!

        J Offline
        J Offline
        Jochen Arndt
        wrote on last edited by
        #3

        You must also check the vt member. When expecting a boolean value, it must be VT_BOOL. When the requested property exists but did not contain a value, VT_EMPTY or VT_NULL are returned (the return type depends on the property value type).

        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