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. CHAR to WCHAR ??

CHAR to WCHAR ??

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
18 Posts 6 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.
  • F Fritzables

    I am trying to write a simple application that is capable of zipping files. To do this I am using ‘LiteZip’. I am writing with Visual C++ 2005. The code which generates the error is: #include "litezip.h" HZIP hz; ZipCreateFile(&hz,"FileName.zip",0); The error message is: error C2664: 'ZipCreateFileW' : cannot convert parameter 2 from 'const char [9]' to 'const WCHAR *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast From what I understand, I need to convert a CHAR to WCHAR. This is done by…. ?? Regards Pete :doh:

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

    Since you have Unicode enabled, try: HZIP hz; ZipCreateFile(&hz,L"FileName.zip",0);

    F 1 Reply Last reply
    0
    • M Mark Salsbery

      Since you have Unicode enabled, try: HZIP hz; ZipCreateFile(&hz,L"FileName.zip",0);

      F Offline
      F Offline
      Fritzables
      wrote on last edited by
      #3

      Mark...... you're a legend !! All Ok now. So what does the 'L' basically do ? Cheers Pete :-D

      M D 2 Replies Last reply
      0
      • F Fritzables

        Mark...... you're a legend !! All Ok now. So what does the 'L' basically do ? Cheers Pete :-D

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

        Fritzables wrote:

        So what does the 'L' basically do ?

        It makes the literal string's type wchar_t instead of char.

        F 1 Reply Last reply
        0
        • M Mark Salsbery

          Fritzables wrote:

          So what does the 'L' basically do ?

          It makes the literal string's type wchar_t instead of char.

          F Offline
          F Offline
          Fritzables
          wrote on last edited by
          #5

          Oooops, now I get a: LNK2028: unresolved token (0A00001B) "extern "C" unsigned long __stdcall ZipCreateFileW(void * *,wchar_t const *,char const *)" (?ZipCreateFileW@@$$J212YGKPAPAXPB_WPBD@Z) referenced in function "public: void __clrcall SystemInitialisation::ListUnmergedFiles(void)" (?ListUnmergedFiles@SystemInitialisation@@$$FQ$AAMXXZ)

          M 1 Reply Last reply
          0
          • F Fritzables

            Oooops, now I get a: LNK2028: unresolved token (0A00001B) "extern "C" unsigned long __stdcall ZipCreateFileW(void * *,wchar_t const *,char const *)" (?ZipCreateFileW@@$$J212YGKPAPAXPB_WPBD@Z) referenced in function "public: void __clrcall SystemInitialisation::ListUnmergedFiles(void)" (?ListUnmergedFiles@SystemInitialisation@@$$FQ$AAMXXZ)

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

            Sounds like you need to link to the LiteZip library. I've never used it but there should be either an import library if it's implemented as a DLL or else a static library. LiteZip.lib? Mark

            F 1 Reply Last reply
            0
            • M Mark Salsbery

              Sounds like you need to link to the LiteZip library. I've never used it but there should be either an import library if it's implemented as a DLL or else a static library. LiteZip.lib? Mark

              F Offline
              F Offline
              Fritzables
              wrote on last edited by
              #7

              Yea, there is both. The LiteZip.dll I placed in the windows\system32 folder while the LIB file I placed in the LIB folder under VC8. Obviously there more I need to do. So I need to write the code in to tell that the DLL is there and where it is ? Pete

              M 1 Reply Last reply
              0
              • F Fritzables

                Yea, there is both. The LiteZip.dll I placed in the windows\system32 folder while the LIB file I placed in the LIB folder under VC8. Obviously there more I need to do. So I need to write the code in to tell that the DLL is there and where it is ? Pete

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

                Fritzables wrote:

                The LiteZip.dll I placed in the windows\system32 folder while the LIB file I placed in the LIB folder under VC8.

                Generally you want to keep 3rd-party dlls in the same folder as your app unless the vendor explicitly states to move it to a system folder. This helps prevent versioning clashes with other applications. The lib file can stay where it was (for the same reason I suppose). This is from VS 2003 so may be a bit different on 2005... In solution explorer - right click your project and select Properties. Go to the Linker/Input section and add the libfile pathname to the Additional Dependencies line. For example "C:\LiteZip\Lib\LiteZip.lib". Substitute the actual path and file name as usual. If there's multiple lib files on the line then separate them with a space. Should link! :) Mark

                PJ ArendsP F 2 Replies Last reply
                0
                • M Mark Salsbery

                  Fritzables wrote:

                  The LiteZip.dll I placed in the windows\system32 folder while the LIB file I placed in the LIB folder under VC8.

                  Generally you want to keep 3rd-party dlls in the same folder as your app unless the vendor explicitly states to move it to a system folder. This helps prevent versioning clashes with other applications. The lib file can stay where it was (for the same reason I suppose). This is from VS 2003 so may be a bit different on 2005... In solution explorer - right click your project and select Properties. Go to the Linker/Input section and add the libfile pathname to the Additional Dependencies line. For example "C:\LiteZip\Lib\LiteZip.lib". Substitute the actual path and file name as usual. If there's multiple lib files on the line then separate them with a space. Should link! :) Mark

                  PJ ArendsP Offline
                  PJ ArendsP Offline
                  PJ Arends
                  wrote on last edited by
                  #9

                  Any reason you did not suggest using a #pragma?

                  #pragma comment(lib, "LiteZip")

                  It's a lot easier, and if the #pragma line is placed in the LiteZip.h header file it is something that one never has to remember to do when using the library.


                  You may be right
                  I may be crazy
                  -- Billy Joel --

                  Within you lies the power for good, use it!!!

                  Within you lies the power for good; Use it!

                  M 1 Reply Last reply
                  0
                  • M Mark Salsbery

                    Fritzables wrote:

                    The LiteZip.dll I placed in the windows\system32 folder while the LIB file I placed in the LIB folder under VC8.

                    Generally you want to keep 3rd-party dlls in the same folder as your app unless the vendor explicitly states to move it to a system folder. This helps prevent versioning clashes with other applications. The lib file can stay where it was (for the same reason I suppose). This is from VS 2003 so may be a bit different on 2005... In solution explorer - right click your project and select Properties. Go to the Linker/Input section and add the libfile pathname to the Additional Dependencies line. For example "C:\LiteZip\Lib\LiteZip.lib". Substitute the actual path and file name as usual. If there's multiple lib files on the line then separate them with a space. Should link! :) Mark

                    F Offline
                    F Offline
                    Fritzables
                    wrote on last edited by
                    #10

                    That's it Mark, Now it compiles and end up with an EXE. Where did you learn all this ?? Just reading out of books or have ya done some courses ? Pete :-D

                    M T 2 Replies Last reply
                    0
                    • F Fritzables

                      That's it Mark, Now it compiles and end up with an EXE. Where did you learn all this ?? Just reading out of books or have ya done some courses ? Pete :-D

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

                      Fritzables wrote:

                      Where did you learn all this ?? Just reading out of books or have ya done some courses ?

                      Lots of books (measured in pounds/Kgs I guess) and I started PC programming before there was Windows :) Man, I'm old. I don't miss command-line compiling/linking/building one bit! I'm still always learning though - that's why it's handy hanging out here. Cheers! Mark

                      1 Reply Last reply
                      0
                      • PJ ArendsP PJ Arends

                        Any reason you did not suggest using a #pragma?

                        #pragma comment(lib, "LiteZip")

                        It's a lot easier, and if the #pragma line is placed in the LiteZip.h header file it is something that one never has to remember to do when using the library.


                        You may be right
                        I may be crazy
                        -- Billy Joel --

                        Within you lies the power for good, use it!!!

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

                        PJ Arends wrote:

                        Any reason you did not suggest using a #pragma?

                        I left that for you to suggest! I suggest you suggest it to the OP :laugh: Thanks for the tip! Mark

                        1 Reply Last reply
                        0
                        • F Fritzables

                          That's it Mark, Now it compiles and end up with an EXE. Where did you learn all this ?? Just reading out of books or have ya done some courses ? Pete :-D

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

                          Fritzables wrote:

                          Where did you learn all this ?? Just reading out of books or have ya done some courses ?

                          you can add libaray file just like adding c++ file~!

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

                          cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and you

                          M 1 Reply Last reply
                          0
                          • F Fritzables

                            Mark...... you're a legend !! All Ok now. So what does the 'L' basically do ? Cheers Pete :-D

                            D Offline
                            D Offline
                            David Crow
                            wrote on last edited by
                            #14

                            Fritzables wrote:

                            So what does the 'L' basically do ?

                            You too can achieve 'legend' status by reading here.


                            "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

                            "Judge not by the eye but by the heart." - Native American Proverb

                            F 1 Reply Last reply
                            0
                            • T ThatsAlok

                              Fritzables wrote:

                              Where did you learn all this ?? Just reading out of books or have ya done some courses ?

                              you can add libaray file just like adding c++ file~!

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

                              cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and you

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

                              ThatsAlok wrote:

                              you can add libaray file just like adding c++ file~!

                              :laugh::laugh::laugh: :doh: Good one! I just looked at some of my projects and I have some added like c++ files and some in the project settings. :rolleyes: In my defense, some of these projects started before Visual C++. O M G

                              T 1 Reply Last reply
                              0
                              • F Fritzables

                                I am trying to write a simple application that is capable of zipping files. To do this I am using ‘LiteZip’. I am writing with Visual C++ 2005. The code which generates the error is: #include "litezip.h" HZIP hz; ZipCreateFile(&hz,"FileName.zip",0); The error message is: error C2664: 'ZipCreateFileW' : cannot convert parameter 2 from 'const char [9]' to 'const WCHAR *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast From what I understand, I need to convert a CHAR to WCHAR. This is done by…. ?? Regards Pete :doh:

                                H Offline
                                H Offline
                                Hamid Taebi
                                wrote on last edited by
                                #16

                                And see here[^] :)


                                WhiteSky


                                1 Reply Last reply
                                0
                                • M Mark Salsbery

                                  ThatsAlok wrote:

                                  you can add libaray file just like adding c++ file~!

                                  :laugh::laugh::laugh: :doh: Good one! I just looked at some of my projects and I have some added like c++ files and some in the project settings. :rolleyes: In my defense, some of these projects started before Visual C++. O M G

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

                                  Mark Salsbery wrote:

                                  In my defense, some of these projects started before Visual C++.

                                  he he he

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

                                  cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and you

                                  1 Reply Last reply
                                  0
                                  • D David Crow

                                    Fritzables wrote:

                                    So what does the 'L' basically do ?

                                    You too can achieve 'legend' status by reading here.


                                    "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

                                    "Judge not by the eye but by the heart." - Native American Proverb

                                    F Offline
                                    F Offline
                                    Fritzables
                                    wrote on last edited by
                                    #18

                                    Thanks Dave, I have come across from using Borland's Delphi, so it's difficult coming to terms with some of the coding. Fritzables.

                                    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