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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. COM
  4. Error info of FileSystemObject

Error info of FileSystemObject

Scheduled Pinned Locked Moved COM
questiontestingbeta-testinghelp
4 Posts 2 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.
  • L Offline
    L Offline
    Lane Yu
    wrote on last edited by
    #1

    I try to use FileSystemObject in VC6 via "#import "scrrun.dll"" IFileSystemPtr spFso(__uuidof(FileSystemObject)); ISupportErrorInfoPtr spSupportE = spFso; HRESULT hrRet = spFso->raw_MoveFolder(_bstr_t(pwszSrc), _bstr_t(pwszDst)); For testing, I assigned pwszSrc and pwszDst with invalid paths. I find that IFileSystem does not support ErrorInfo coz the interface pointer in spSupportE is NULL. The value of hrRet is 0x800a004c, which can not be processed by FormatMessage(). So after MoveFolder() fails, I can't get any error message. However, I used VB to call the same function and got error message "Path not found". How does VB do that? How can I get the same message in VC?

    S 1 Reply Last reply
    0
    • L Lane Yu

      I try to use FileSystemObject in VC6 via "#import "scrrun.dll"" IFileSystemPtr spFso(__uuidof(FileSystemObject)); ISupportErrorInfoPtr spSupportE = spFso; HRESULT hrRet = spFso->raw_MoveFolder(_bstr_t(pwszSrc), _bstr_t(pwszDst)); For testing, I assigned pwszSrc and pwszDst with invalid paths. I find that IFileSystem does not support ErrorInfo coz the interface pointer in spSupportE is NULL. The value of hrRet is 0x800a004c, which can not be processed by FormatMessage(). So after MoveFolder() fails, I can't get any error message. However, I used VB to call the same function and got error message "Path not found". How does VB do that? How can I get the same message in VC?

      S Offline
      S Offline
      Steve S
      wrote on last edited by
      #2

      Well, 800a004c is CTL_E_PATHNOTFOUND (olectl.h), so you probably need to point FormatMessage at the right DLL...

      Steve S Developer for hire

      L 1 Reply Last reply
      0
      • S Steve S

        Well, 800a004c is CTL_E_PATHNOTFOUND (olectl.h), so you probably need to point FormatMessage at the right DLL...

        Steve S Developer for hire

        L Offline
        L Offline
        Lane Yu
        wrote on last edited by
        #3

        I think the common way of using FormatMessage is like this: LPWSTR pwszMsg = NULL; FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL,hr, 0, (LPWSTR)&pwszMsg, 0, NULL); How can I know which DLL to point and generate correct message? Thanks.

        S 1 Reply Last reply
        0
        • L Lane Yu

          I think the common way of using FormatMessage is like this: LPWSTR pwszMsg = NULL; FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL,hr, 0, (LPWSTR)&pwszMsg, 0, NULL); How can I know which DLL to point and generate correct message? Thanks.

          S Offline
          S Offline
          Steve S
          wrote on last edited by
          #4

          You could try the one you're #import-ing. You're quite right about that being the most common way, though.

          Steve S Developer for hire

          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