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. About the path

About the path

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
19 Posts 7 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.
  • C capint

    I don't understand. So, I give an example: CImage Image; Image.Load("D:\Test.bmp") <-- can't load Image.Load("D:\\Test.bmp") <-- can load What happens when a function retrieves the path D:\Test.bmp? How can we use it ?

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

    capint wrote:

    Image.Load("D:\Test.bmp") <-- can't load

    Because D:est.bmp (or maybe D:<tab>est.bmp) is what actually gets sent as the argument to Load().

    "Love people and use things, not love things and use people." - Unknown

    "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

    C 1 Reply Last reply
    0
    • S sashoalm

      you could alternatively use / , most windows functions accept it, and the standard C library functions automatically convert it. \\ is ugly especially in long paths.

      C Offline
      C Offline
      capint
      wrote on last edited by
      #8

      I still can't understand. I know about escape sequences :^) U mean that the path we receive from window functions is OK ( we don't need to replace although they just have "\"), is that right ?

      D 1 Reply Last reply
      0
      • C capint

        I still can't understand. I know about escape sequences :^) U mean that the path we receive from window functions is OK ( we don't need to replace although they just have "\"), is that right ?

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

        capint wrote:

        U mean that the path we receive from window functions is OK

        Yes, because those are not being seen by the compiler. What happens at runtime is completely different.

        "Love people and use things, not love things and use people." - Unknown

        "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

        C 1 Reply Last reply
        0
        • D David Crow

          capint wrote:

          U mean that the path we receive from window functions is OK

          Yes, because those are not being seen by the compiler. What happens at runtime is completely different.

          "Love people and use things, not love things and use people." - Unknown

          "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

          C Offline
          C Offline
          capint
          wrote on last edited by
          #10

          My problem is that. I receive the string from the function SystemParametersInfo and I use that string to load by Image.Load. It doesn't work :(

          D 1 Reply Last reply
          0
          • C capint

            My problem is that. I receive the string from the function SystemParametersInfo and I use that string to load by Image.Load. It doesn't work :(

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

            capint wrote:

            It doesn't work

            Then something else is wrong. Does the file actually exist? What does Load() return?

            "Love people and use things, not love things and use people." - Unknown

            "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

            C 1 Reply Last reply
            0
            • D David Crow

              capint wrote:

              It doesn't work

              Then something else is wrong. Does the file actually exist? What does Load() return?

              "Love people and use things, not love things and use people." - Unknown

              "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

              C Offline
              C Offline
              capint
              wrote on last edited by
              #12

              All my code is here : TCHAR * Temp; Temp = new TCHAR[100]; CString str; SystemParametersInfo(SPI_GETDESKWALLPAPER,100,Temp,0); CImage Image; str = Temp; Image.Load(str); Image.ReleaseDC(); Image.Save(_T("D:\\Temp\\Desktop.bmp")); I debuged & I saw clearly the path, of course, it exits When I replace str by another string created manually, it works

              D M 2 Replies Last reply
              0
              • C capint

                All my code is here : TCHAR * Temp; Temp = new TCHAR[100]; CString str; SystemParametersInfo(SPI_GETDESKWALLPAPER,100,Temp,0); CImage Image; str = Temp; Image.Load(str); Image.ReleaseDC(); Image.Save(_T("D:\\Temp\\Desktop.bmp")); I debuged & I saw clearly the path, of course, it exits When I replace str by another string created manually, it works

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

                Which statement is failing?

                "Love people and use things, not love things and use people." - Unknown

                "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                C 1 Reply Last reply
                0
                • D David Crow

                  Which statement is failing?

                  "Love people and use things, not love things and use people." - Unknown

                  "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                  C Offline
                  C Offline
                  capint
                  wrote on last edited by
                  #14

                  No statement is failing. It just doesn't do anything. Actually, when I replace "\" by "/", it works. But I still wonder :sigh:

                  D 1 Reply Last reply
                  0
                  • D David Crow

                    capint wrote:

                    Image.Load("D:\Test.bmp") <-- can't load

                    Because D:est.bmp (or maybe D:<tab>est.bmp) is what actually gets sent as the argument to Load().

                    "Love people and use things, not love things and use people." - Unknown

                    "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                    C Offline
                    C Offline
                    CPallini
                    wrote on last edited by
                    #15

                    DavidCrow wrote:

                    D:est.bmp (or maybe D:est.bmp)

                    or even D:est.bmp! :-D (BTW I got what you meant, anyway kidding is irresistible to me...)

                    If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                    This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

                    R 1 Reply Last reply
                    0
                    • C capint

                      No statement is failing. It just doesn't do anything. Actually, when I replace "\" by "/", it works. But I still wonder :sigh:

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

                      capint wrote:

                      No statement is failing.

                      How are you verifying this?

                      capint wrote:

                      Actually, when I replace "\" by "/", it works. But I still wonder

                      Single slashes (like those used on Unix machines) can be used in place of double backslashes.

                      "Love people and use things, not love things and use people." - Unknown

                      "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                      1 Reply Last reply
                      0
                      • C capint

                        All my code is here : TCHAR * Temp; Temp = new TCHAR[100]; CString str; SystemParametersInfo(SPI_GETDESKWALLPAPER,100,Temp,0); CImage Image; str = Temp; Image.Load(str); Image.ReleaseDC(); Image.Save(_T("D:\\Temp\\Desktop.bmp")); I debuged & I saw clearly the path, of course, it exits When I replace str by another string created manually, it works

                        M Offline
                        M Offline
                        Member 4194593
                        wrote on last edited by
                        #17

                        You realize, of course, that the path can be up to 260 characters long?

                        1 Reply Last reply
                        0
                        • C CPallini

                          DavidCrow wrote:

                          D:est.bmp (or maybe D:est.bmp)

                          or even D:est.bmp! :-D (BTW I got what you meant, anyway kidding is irresistible to me...)

                          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

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

                          :laugh: You're a such a bad guy.

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

                          C 1 Reply Last reply
                          0
                          • R Rajesh R Subramanian

                            :laugh: You're a such a bad guy.

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

                            C Offline
                            C Offline
                            CPallini
                            wrote on last edited by
                            #19

                            I know, buddy! :-D

                            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

                            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