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. FindFirstFile wants an unsigned short* ?

FindFirstFile wants an unsigned short* ?

Scheduled Pinned Locked Moved C / C++ / MFC
c++regexjsonhelpquestion
7 Posts 3 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 Offline
    F Offline
    Fahr
    wrote on last edited by
    #1

    Hello, I'm trying to use the API FindFirstFile in a non-MFC DLL using VC++ 6 and I get the following error on compile: error C2664: 'FindFirstFileW' : cannot convert parameter 1 from 'const char *' to 'const unsigned short *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast On this line: HANDLE Finding = FindFirstFile("C:\\*.*", &FindFileData); Now I can be stupid, but I don't think that a pattern, which is described as an LPCSTR in the MSDN, would ask for an unsigned short*... Can anybody tell me what I'm doing wrong here? Thanks, - Fahr

    C 1 Reply Last reply
    0
    • F Fahr

      Hello, I'm trying to use the API FindFirstFile in a non-MFC DLL using VC++ 6 and I get the following error on compile: error C2664: 'FindFirstFileW' : cannot convert parameter 1 from 'const char *' to 'const unsigned short *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast On this line: HANDLE Finding = FindFirstFile("C:\\*.*", &FindFileData); Now I can be stupid, but I don't think that a pattern, which is described as an LPCSTR in the MSDN, would ask for an unsigned short*... Can anybody tell me what I'm doing wrong here? Thanks, - Fahr

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      any chance you're doing a Unicode build? -c


      I'm not the droid you're looking for.

      ThumbNailer

      L F 2 Replies Last reply
      0
      • C Chris Losinger

        any chance you're doing a Unicode build? -c


        I'm not the droid you're looking for.

        ThumbNailer

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        That why also my guess. Have you tried

        HANDLE Finding = FindFirstFile(_T("C:\\*.*"), &FindFileData);

        ? regards

        F 1 Reply Last reply
        0
        • C Chris Losinger

          any chance you're doing a Unicode build? -c


          I'm not the droid you're looking for.

          ThumbNailer

          F Offline
          F Offline
          Fahr
          wrote on last edited by
          #4

          That could very well be, how would I check that? I DID tweak a lot of the compler and linker settings... How is that related anyways? - Fahr

          C 1 Reply Last reply
          0
          • L Lost User

            That why also my guess. Have you tried

            HANDLE Finding = FindFirstFile(_T("C:\\*.*"), &FindFileData);

            ? regards

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

            Well, that seems to work (could you maybe also explain WHY it works?) Now I get an error on this: FString temp = ANSI_TO_TCHAR(FindFileData.cFileName); it seems to be related, too, the error reads; error C2664: 'winGetSizeUNICODE' : cannot convert parameter 1 from 'unsigned short [260]' to 'const char *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast a _T() or L() doesn't work here tho :S - Fahr

            F 1 Reply Last reply
            0
            • F Fahr

              Well, that seems to work (could you maybe also explain WHY it works?) Now I get an error on this: FString temp = ANSI_TO_TCHAR(FindFileData.cFileName); it seems to be related, too, the error reads; error C2664: 'winGetSizeUNICODE' : cannot convert parameter 1 from 'unsigned short [260]' to 'const char *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast a _T() or L() doesn't work here tho :S - Fahr

              F Offline
              F Offline
              Fahr
              wrote on last edited by
              #6

              That's fixed, apparently the ANSI_TO_TCHAR was not needed cuz it's already unicode. My bad... Tho I still don't get why it works like this or not... - Fahr

              1 Reply Last reply
              0
              • F Fahr

                That could very well be, how would I check that? I DID tweak a lot of the compler and linker settings... How is that related anyways? - Fahr

                C Offline
                C Offline
                Chris Losinger
                wrote on last edited by
                #7

                FindFirstFileW is the wide-char version of FindFirstFile. somehow, you've made the compiler think it needs be using this version instead of FindFirstFileA (the single-byte version).


                I'm not the droid you're looking for.

                ThumbNailer

                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