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 convert CString to WCHAR*?

How to convert CString to WCHAR*?

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
9 Posts 5 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.
  • T Offline
    T Offline
    TooShy2Talk
    wrote on last edited by
    #1

    Hi, I need to convert CString to WCHAR* but I don't know how. If you know how please tell me. Your comment will be a big help. Thank you.

    S M 2 Replies Last reply
    0
    • T TooShy2Talk

      Hi, I need to convert CString to WCHAR* but I don't know how. If you know how please tell me. Your comment will be a big help. Thank you.

      S Offline
      S Offline
      Sameerkumar Namdeo
      wrote on last edited by
      #2

      If your app is UNICODE enabled then CString can be used at the place of WCHAR* by using its str.GetBuffer() function. If not then use MultiByteToWideChar() function to convert CString to WCHAR*

      T 1 Reply Last reply
      0
      • T TooShy2Talk

        Hi, I need to convert CString to WCHAR* but I don't know how. If you know how please tell me. Your comment will be a big help. Thank you.

        M Offline
        M Offline
        Mark Salsbery
        wrote on last edited by
        #3

        In addition to ccpptrain's reply... If your app is UNICODE enabled then CString has a casting operator so you can use the string anywhere a const WCHAR* is expected...without having to use GetBuffer(). Mark

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        T R 2 Replies Last reply
        0
        • S Sameerkumar Namdeo

          If your app is UNICODE enabled then CString can be used at the place of WCHAR* by using its str.GetBuffer() function. If not then use MultiByteToWideChar() function to convert CString to WCHAR*

          T Offline
          T Offline
          TooShy2Talk
          wrote on last edited by
          #4

          Thank you very much to your reply. It was very helpful.

          1 Reply Last reply
          0
          • M Mark Salsbery

            In addition to ccpptrain's reply... If your app is UNICODE enabled then CString has a casting operator so you can use the string anywhere a const WCHAR* is expected...without having to use GetBuffer(). Mark

            Mark Salsbery Microsoft MVP - Visual C++ :java:

            T Offline
            T Offline
            TooShy2Talk
            wrote on last edited by
            #5

            Thanks for the time. It helps a lot.

            1 Reply Last reply
            0
            • M Mark Salsbery

              In addition to ccpptrain's reply... If your app is UNICODE enabled then CString has a casting operator so you can use the string anywhere a const WCHAR* is expected...without having to use GetBuffer(). Mark

              Mark Salsbery Microsoft MVP - Visual C++ :java:

              R Offline
              R Offline
              Rajesh R Subramanian
              wrote on last edited by
              #6

              Mark Salsbery wrote:

              .without having to use GetBuffer().

              What! No GetBuffer()? :rolleyes: That sucks.

              Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

              M T 2 Replies Last reply
              0
              • R Rajesh R Subramanian

                Mark Salsbery wrote:

                .without having to use GetBuffer().

                What! No GetBuffer()? :rolleyes: That sucks.

                Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

                M Offline
                M Offline
                Mark Salsbery
                wrote on last edited by
                #7

                Hehe ;P

                Mark Salsbery Microsoft MVP - Visual C++ :java:

                1 Reply Last reply
                0
                • R Rajesh R Subramanian

                  Mark Salsbery wrote:

                  .without having to use GetBuffer().

                  What! No GetBuffer()? :rolleyes: That sucks.

                  Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

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

                  Rajesh R Subramanian wrote:

                  What! No GetBuffer()? That sucks.

                  I know, thats really sucks,, but come handy somewhere!

                  "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
                  Never mind - my own stupidity is the source of every "problem" - Mixture

                  cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You/codeProject$$>

                  R 1 Reply Last reply
                  0
                  • T ThatsAlok

                    Rajesh R Subramanian wrote:

                    What! No GetBuffer()? That sucks.

                    I know, thats really sucks,, but come handy somewhere!

                    "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
                    Never mind - my own stupidity is the source of every "problem" - Mixture

                    cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You/codeProject$$>

                    R Offline
                    R Offline
                    Rajesh R Subramanian
                    wrote on last edited by
                    #9

                    ThatsAlok wrote:

                    but come handy somewhere!

                    Not the best thing to have handy while converting a CString to a WCHAR* though. :)

                    Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

                    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