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. Why did ParseDisplayName fail ?

Why did ParseDisplayName fail ?

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

    Dear gurus, I'm having a problem in using ParseDisplayName. 1) I have a path of USB drive, such as: G:\ 2) I pass this driver path into my function, which will call ParseDisplayName to get PIDL item, as below: LPITEMIDLIST CTemp::getItemIDList( CString p_strPath ) { USES_CONVERSION; if( p_strPath.IsEmpty() ) { return NULL; } LPITEMIDLIST l_pIDL; LPSHELLFOLDER pDesktopFolder; if( ::SHGetDesktopFolder( &pDesktopFolder ) != NOERROR ) { return NULL; } OLECHAR ochPath[MAX_PATH]; ULONG chEaten; ULONG dwAttributes; HRESULT hRes; ::MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, W2A(p_strPath), -1, ochPath, MAX_PATH ); hRes = pDesktopFolder->ParseDisplayName( NULL, NULL, ochPath, &chEaten, &l_pIDL, &dwAttributes); pDesktopFolder->Release(); return l_pIDL; } 3) The hRes result is 0x80070003 指定されたパスが見つかりません. I don't know why it was failed. I also try another way to solve this bug and I realize that, if i access to this USB drive before calling ParseDisplayName, this method ParseDisplayName always return good result, S_OK, such as: a) Call the function ParseDisplayName at the first time, right after calling ParseDisplayName again, the hRes result will be S_OK. b) Declare a file path variable to one file in USB drive. Call ParseDisplayName with this file path, then call ParseDisplayName with the USB drive path, the hRes result will be S_OK. c) Use while loop to browse each drive after using CSIDL_DRIVES, then calling ParseDisplayName, the hRes result will be S_OK. So can you help me to explain two issues: 1) Why does the ParseDisplayName method fail in this case ? 2) Why does the ParseDisplayName method success after accessing the USB drive at first time? If anybody here had the same situation like mine, please help me to clarify the mystery surrounding this phenomenon. I'm looking forward to seeing your replies. Best regards, Jetflower

    N M L 3 Replies Last reply
    0
    • T Thang

      Dear gurus, I'm having a problem in using ParseDisplayName. 1) I have a path of USB drive, such as: G:\ 2) I pass this driver path into my function, which will call ParseDisplayName to get PIDL item, as below: LPITEMIDLIST CTemp::getItemIDList( CString p_strPath ) { USES_CONVERSION; if( p_strPath.IsEmpty() ) { return NULL; } LPITEMIDLIST l_pIDL; LPSHELLFOLDER pDesktopFolder; if( ::SHGetDesktopFolder( &pDesktopFolder ) != NOERROR ) { return NULL; } OLECHAR ochPath[MAX_PATH]; ULONG chEaten; ULONG dwAttributes; HRESULT hRes; ::MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, W2A(p_strPath), -1, ochPath, MAX_PATH ); hRes = pDesktopFolder->ParseDisplayName( NULL, NULL, ochPath, &chEaten, &l_pIDL, &dwAttributes); pDesktopFolder->Release(); return l_pIDL; } 3) The hRes result is 0x80070003 指定されたパスが見つかりません. I don't know why it was failed. I also try another way to solve this bug and I realize that, if i access to this USB drive before calling ParseDisplayName, this method ParseDisplayName always return good result, S_OK, such as: a) Call the function ParseDisplayName at the first time, right after calling ParseDisplayName again, the hRes result will be S_OK. b) Declare a file path variable to one file in USB drive. Call ParseDisplayName with this file path, then call ParseDisplayName with the USB drive path, the hRes result will be S_OK. c) Use while loop to browse each drive after using CSIDL_DRIVES, then calling ParseDisplayName, the hRes result will be S_OK. So can you help me to explain two issues: 1) Why does the ParseDisplayName method fail in this case ? 2) Why does the ParseDisplayName method success after accessing the USB drive at first time? If anybody here had the same situation like mine, please help me to clarify the mystery surrounding this phenomenon. I'm looking forward to seeing your replies. Best regards, Jetflower

      N Offline
      N Offline
      Naveen
      wrote on last edited by
      #2

      I not sure but, but I think had faced the same problem some moths ago and at that time when I changed the CoInitializeEx to CoInitialize( or reverse ) the problem go fixed. Could you please try changing it?

      nave [My Articles] [My Blog]

      M 1 Reply Last reply
      0
      • T Thang

        Dear gurus, I'm having a problem in using ParseDisplayName. 1) I have a path of USB drive, such as: G:\ 2) I pass this driver path into my function, which will call ParseDisplayName to get PIDL item, as below: LPITEMIDLIST CTemp::getItemIDList( CString p_strPath ) { USES_CONVERSION; if( p_strPath.IsEmpty() ) { return NULL; } LPITEMIDLIST l_pIDL; LPSHELLFOLDER pDesktopFolder; if( ::SHGetDesktopFolder( &pDesktopFolder ) != NOERROR ) { return NULL; } OLECHAR ochPath[MAX_PATH]; ULONG chEaten; ULONG dwAttributes; HRESULT hRes; ::MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, W2A(p_strPath), -1, ochPath, MAX_PATH ); hRes = pDesktopFolder->ParseDisplayName( NULL, NULL, ochPath, &chEaten, &l_pIDL, &dwAttributes); pDesktopFolder->Release(); return l_pIDL; } 3) The hRes result is 0x80070003 指定されたパスが見つかりません. I don't know why it was failed. I also try another way to solve this bug and I realize that, if i access to this USB drive before calling ParseDisplayName, this method ParseDisplayName always return good result, S_OK, such as: a) Call the function ParseDisplayName at the first time, right after calling ParseDisplayName again, the hRes result will be S_OK. b) Declare a file path variable to one file in USB drive. Call ParseDisplayName with this file path, then call ParseDisplayName with the USB drive path, the hRes result will be S_OK. c) Use while loop to browse each drive after using CSIDL_DRIVES, then calling ParseDisplayName, the hRes result will be S_OK. So can you help me to explain two issues: 1) Why does the ParseDisplayName method fail in this case ? 2) Why does the ParseDisplayName method success after accessing the USB drive at first time? If anybody here had the same situation like mine, please help me to clarify the mystery surrounding this phenomenon. I'm looking forward to seeing your replies. Best regards, Jetflower

        M Offline
        M Offline
        Michel Godfroid
        wrote on last edited by
        #3

        Your HRESULT indicates WIN32/PATH_NOT_FOUND. The only thing I can imagine is that the shell has not 'seen' your USB drive yet (i.e. it hasn't handled the mount on the G: reparse point and updated it's data structures). Calling into the shell once (through ::SHGetDesktopFolder) causes it to execute some code, and probably notice the mount event. Subsequent calls will the succeed.

        1 Reply Last reply
        0
        • N Naveen

          I not sure but, but I think had faced the same problem some moths ago and at that time when I changed the CoInitializeEx to CoInitialize( or reverse ) the problem go fixed. Could you please try changing it?

          nave [My Articles] [My Blog]

          M Offline
          M Offline
          Michel Godfroid
          wrote on last edited by
          #4

          Yes, that could be it. If your threading model is wrong, the shell won't be able to execute except when you call in to it, which explains that it does not see your drive before you allow it execute. See my other answer on this thread.

          1 Reply Last reply
          0
          • T Thang

            Dear gurus, I'm having a problem in using ParseDisplayName. 1) I have a path of USB drive, such as: G:\ 2) I pass this driver path into my function, which will call ParseDisplayName to get PIDL item, as below: LPITEMIDLIST CTemp::getItemIDList( CString p_strPath ) { USES_CONVERSION; if( p_strPath.IsEmpty() ) { return NULL; } LPITEMIDLIST l_pIDL; LPSHELLFOLDER pDesktopFolder; if( ::SHGetDesktopFolder( &pDesktopFolder ) != NOERROR ) { return NULL; } OLECHAR ochPath[MAX_PATH]; ULONG chEaten; ULONG dwAttributes; HRESULT hRes; ::MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, W2A(p_strPath), -1, ochPath, MAX_PATH ); hRes = pDesktopFolder->ParseDisplayName( NULL, NULL, ochPath, &chEaten, &l_pIDL, &dwAttributes); pDesktopFolder->Release(); return l_pIDL; } 3) The hRes result is 0x80070003 指定されたパスが見つかりません. I don't know why it was failed. I also try another way to solve this bug and I realize that, if i access to this USB drive before calling ParseDisplayName, this method ParseDisplayName always return good result, S_OK, such as: a) Call the function ParseDisplayName at the first time, right after calling ParseDisplayName again, the hRes result will be S_OK. b) Declare a file path variable to one file in USB drive. Call ParseDisplayName with this file path, then call ParseDisplayName with the USB drive path, the hRes result will be S_OK. c) Use while loop to browse each drive after using CSIDL_DRIVES, then calling ParseDisplayName, the hRes result will be S_OK. So can you help me to explain two issues: 1) Why does the ParseDisplayName method fail in this case ? 2) Why does the ParseDisplayName method success after accessing the USB drive at first time? If anybody here had the same situation like mine, please help me to clarify the mystery surrounding this phenomenon. I'm looking forward to seeing your replies. Best regards, Jetflower

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

            Hi Jetflower, What is the concurrency model of your thread? Is it multi-threaded? INFO: Calling Shell Functions and Interfaces from a Multithreaded Apartment[^] Best Wishes, -David Delaune

            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