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. CString to LPCWSTR conversion ???

CString to LPCWSTR conversion ???

Scheduled Pinned Locked Moved C / C++ / MFC
designhelptutorialquestion
4 Posts 4 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.
  • S Offline
    S Offline
    shoonya
    wrote on last edited by
    #1

    does anybody know how to convert from "CString" to "LPCWSTR" ? i am using BITS in my program and the "IBackgroundCopyJob::AddFile" function takes input only as HRESULT AddFile(LPCWSTR pRemoteName,LPCWSTR pLocalName); i wish to pass CString taken from the user interface to the BITS function.:) didn't get much help from MSDN :((

    C T C 3 Replies Last reply
    0
    • S shoonya

      does anybody know how to convert from "CString" to "LPCWSTR" ? i am using BITS in my program and the "IBackgroundCopyJob::AddFile" function takes input only as HRESULT AddFile(LPCWSTR pRemoteName,LPCWSTR pLocalName); i wish to pass CString taken from the user interface to the BITS function.:) didn't get much help from MSDN :((

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      I found MSDN to be quite informative.[^] Don't forget to call ReleaseBuffer when you finish with it. I take it back, you're trying to create a wide string. Try this[^] instead. A _bstr_t will convert between narrow and wide strings for you ( by using these macros ), but is not of much use otherwise. Christian Graus - Microsoft MVP - C++

      1 Reply Last reply
      0
      • S shoonya

        does anybody know how to convert from "CString" to "LPCWSTR" ? i am using BITS in my program and the "IBackgroundCopyJob::AddFile" function takes input only as HRESULT AddFile(LPCWSTR pRemoteName,LPCWSTR pLocalName); i wish to pass CString taken from the user interface to the BITS function.:) didn't get much help from MSDN :((

        T Offline
        T Offline
        ThatsAlok
        wrote on last edited by
        #3

        Look at this http://www.codeproject.com/script/comments/forums.asp?msg=1124974&forumid=1647#xx1124974xx[^]

        "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

        cheers, Alok Gupta

        1 Reply Last reply
        0
        • S shoonya

          does anybody know how to convert from "CString" to "LPCWSTR" ? i am using BITS in my program and the "IBackgroundCopyJob::AddFile" function takes input only as HRESULT AddFile(LPCWSTR pRemoteName,LPCWSTR pLocalName); i wish to pass CString taken from the user interface to the BITS function.:) didn't get much help from MSDN :((

          C Offline
          C Offline
          cmk
          wrote on last edited by
          #4

          The easiest way would be to compile you program to use UNICODE strings. In Project - Settings - C/C++ : Preprocessor definitions make sure _UNICODE is defined and not _ANSI or _MBCS. This will make CString use wide chars and allow an auto cast down to LPCWSTR. ...cmk Save the whales - collect the whole set

          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