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. Problem Converting string/const char* to OLECHAR FAR*

Problem Converting string/const char* to OLECHAR FAR*

Scheduled Pinned Locked Moved C / C++ / MFC
helpcom
2 Posts 2 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
    CoffeeAddict19
    wrote on last edited by
    #1

    The code I'm trying to use: std::string url = "http://www.psc-range.com/"; browser->Navigate(SysAllocString(url.c_str()),&vFlags,&vTargetFrameName,NULL,NULL); The error: 'SysAllocString' : cannot convert parameter 1 from 'const char *' to 'const OLECHAR *' I've managed to get this working: browser->Navigate(SysAllocString(L"http://www.psc-range.com/"),&vFlags,&vTargetFrameName,NULL,NULL); Unfortunately I need to get it work with any valid URL, not just one. If someone would please point me in the right direction I would appreciate it. :)

    C 1 Reply Last reply
    0
    • C CoffeeAddict19

      The code I'm trying to use: std::string url = "http://www.psc-range.com/"; browser->Navigate(SysAllocString(url.c_str()),&vFlags,&vTargetFrameName,NULL,NULL); The error: 'SysAllocString' : cannot convert parameter 1 from 'const char *' to 'const OLECHAR *' I've managed to get this working: browser->Navigate(SysAllocString(L"http://www.psc-range.com/"),&vFlags,&vTargetFrameName,NULL,NULL); Unfortunately I need to get it work with any valid URL, not just one. If someone would please point me in the right direction I would appreciate it. :)

      C Offline
      C Offline
      Code o mat
      wrote on last edited by
      #2

      Seems like OLECHAR wants a unicode string and you are giving it an ASCII string, try converting your url to unicode, maybe like this:

      std::basic_string<WCHAR> wide_url = L("http:\\...");
      browser->Navigate(SysAllocString(wide_url.c_str()),&vFlags,&vTargetFrameName,NULL,NULL);

      > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <

      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