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. Create Directory

Create Directory

Scheduled Pinned Locked Moved C / C++ / MFC
question
6 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.
  • M Offline
    M Offline
    manu_2205
    wrote on last edited by
    #1

    Hi int result=CreateDirectory(LPCSTR(Dir_Name),NULL); The above statement return 0 if i use WCHAR pointer(Dir_Name). why ?

    manu

    R K 2 Replies Last reply
    0
    • M manu_2205

      Hi int result=CreateDirectory(LPCSTR(Dir_Name),NULL); The above statement return 0 if i use WCHAR pointer(Dir_Name). why ?

      manu

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

      manu_2205 wrote:

      int result=CreateDirectory(LPCSTR(Dir_Name),NULL);

      1. Why do you need that LPCSTR there? 2. Is your project unicode aware?


      Nobody can give you wiser advice than yourself. - Cicero ப்ரம்மா

      M 1 Reply Last reply
      0
      • R Rajesh R Subramanian

        manu_2205 wrote:

        int result=CreateDirectory(LPCSTR(Dir_Name),NULL);

        1. Why do you need that LPCSTR there? 2. Is your project unicode aware?


        Nobody can give you wiser advice than yourself. - Cicero ப்ரம்மா

        M Offline
        M Offline
        manu_2205
        wrote on last edited by
        #3

        ya project unicode aware , if i do't write LPCSTR it generate compile time error. "error C2664: 'CreateDirectoryA' : cannot convert parameter 1 from 'WCHAR *' to 'LPCSTR'"

        manu

        T R 2 Replies Last reply
        0
        • M manu_2205

          ya project unicode aware , if i do't write LPCSTR it generate compile time error. "error C2664: 'CreateDirectoryA' : cannot convert parameter 1 from 'WCHAR *' to 'LPCSTR'"

          manu

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

          manu_2205 wrote:

          "error C2664: 'CreateDirectoryA' : cannot convert parameter 1 from 'WCHAR *' to 'LPCSTR'"

          dont use LPCSTR, but CA2W()


          Don't know where to start ?
          Refer the Forums Guidelines and ask a friend

          [VisualCalc 3.0][Flags Beginner's Guide]

          1 Reply Last reply
          0
          • M manu_2205

            ya project unicode aware , if i do't write LPCSTR it generate compile time error. "error C2664: 'CreateDirectoryA' : cannot convert parameter 1 from 'WCHAR *' to 'LPCSTR'"

            manu

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

            manu_2205 wrote:

            'CreateDirectoryA

            If your project is unicode aware, then how is the ANSI version of a function being called? Are you making a call explicitly to the CreateDirectoryA() or are you just calling CreateDirectory()?

            manu_2205 wrote:

            ya project unicode aware

            Now what do you mean by this? Have you replaced _MBCS with _UNICODE in the preprocessor definitions? ( project->settings->c/c++->preprocessor definitions )


            Nobody can give you wiser advice than yourself. - Cicero ப்ரம்மா

            1 Reply Last reply
            0
            • M manu_2205

              Hi int result=CreateDirectory(LPCSTR(Dir_Name),NULL); The above statement return 0 if i use WCHAR pointer(Dir_Name). why ?

              manu

              K Offline
              K Offline
              KarstenK
              wrote on last edited by
              #6

              LPCSTR(Dir_Name) is a bug. You have to convert the WCHAR to LPCSTR in another string.:mad: Maybe you can use CreateDirectoryW( Dir_Name,NULL);//with a big W for WCHAR

              Greetings from Germany

              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