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. Problems with VariantChangeType and VT_BOOL in CE

Problems with VariantChangeType and VT_BOOL in CE

Scheduled Pinned Locked Moved C / C++ / MFC
questiondebuggingjsonhelp
1 Posts 1 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
    Paul M Watt
    wrote on last edited by
    #1

    Hi All, I have discovered that when I convert a BSTR to both VT_I4 or VT_BOOL format with VariantChangeType, a second thread appears in my application, and in most cases simply sits in the background suspended. If I try to context switch to that thread through the debugger and watch where it goes, my connection to the debugger is lost and I must warmboot my device. If I use VariantChangeType to convert from a long to a BSTR, this errent thread does not appear. One final note, when the program shuts down with this errent thread, an exception is thrown, invalid access, probably because of that other thread. Has anyone run into this, or is there any information on what is going on, or how a developer is supposed to work around this? Here is the code for this program to test this problem. Thanks ----------------------------------------------- #include <windows.h> //C: Link in the library that contains the Variant functions. #pragma comment(linker, "/defaultlib:oleaut32.lib") int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { //C: Initialize the variant object. VARIANT v; ::VariantInit(&v); //C: Test the different conversions independantly. #ifdef BSTR_TEST v.vt = VT_I4; v.lVal = -1; ::VariantChangeType(&v, &v, 0, VT_BSTR); BSTR bstr = v.bstrVal; //C: No extra thread, PASSES. #elif defined(LONG_TEST) v.vt = VT_BSTR; v.bstrVal = ::SysAllocString(L"-1"); ::VariantChangeType(&v, &v, 0, VT_I4); long l = v.lVal; //C: At this point a second thread will have been created. FAILS #else v.vt = VT_BSTR; v.bstrVal = ::SysAllocString(L"-1"); ::VariantChangeType(&v, &v, 0, VT_BOOL); VARIANT_BOOL b = v.boolVal; //C: At this point a second thread will have been created. FAILS #endif //C: Free resources. ::VariantClear(&v); return 0; } //C: If the second thread is created, when the program exits, an exception is thrown.


    Build a man a fire, and he will be warm for a day
    Light a man on fire, and he will be warm for the rest of his life!

    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