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. ShellExecute() launch .CHM and PDF file not work in Window 7

ShellExecute() launch .CHM and PDF file not work in Window 7

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionc++
25 Posts 6 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.
  • A Andraw111

    Yes, you are right, ShellExecuteEx() return true or false. But still cannot solve my problem.

    C Offline
    C Offline
    Charles Oppermann
    wrote on last edited by
    #21

    Andraw111 wrote:

    Yes, you are right, ShellExecuteEx() return true or false.
    But still cannot solve my problem.

    Okay, but what is it returning? True or False? If false, did you check GetLastError()? What was it's value?

    /* Charles Oppermann */ http://weblogs.asp.net/chuckop

    A 2 Replies Last reply
    0
    • C Charles Oppermann

      Andraw111 wrote:

      Yes, you are right, ShellExecuteEx() return true or false.
      But still cannot solve my problem.

      Okay, but what is it returning? True or False? If false, did you check GetLastError()? What was it's value?

      /* Charles Oppermann */ http://weblogs.asp.net/chuckop

      A Offline
      A Offline
      Andraw111
      wrote on last edited by
      #22

      Thanks for reply, it return 8. But strange thing is that if I create a brand new MFC project and use the same codes to open .CHM file, it works fine, why?

      C 1 Reply Last reply
      0
      • C Charles Oppermann

        Andraw111 wrote:

        Yes, you are right, ShellExecuteEx() return true or false.
        But still cannot solve my problem.

        Okay, but what is it returning? True or False? If false, did you check GetLastError()? What was it's value?

        /* Charles Oppermann */ http://weblogs.asp.net/chuckop

        A Offline
        A Offline
        Andraw111
        wrote on last edited by
        #23

        Finally I found what cause the .CHM file cannot open in Window 7. In my MFC application, I have a project setting: Link -> Output ->Reserve field, I put "0x40000000". I create a testing application, if I don't set "0x40000000" to Reserve field, it works fine, otherwise, it cannot open .CHM file in Window 7. Even I know the reason, I still cannot solve the problem, since our project is very large, if I remove that setting, when I run my application I get "XX MFC application has encountered a problem and needs to close....".

        1 Reply Last reply
        0
        • A Andraw111

          Thanks for reply, it return 8. But strange thing is that if I create a brand new MFC project and use the same codes to open .CHM file, it works fine, why?

          C Offline
          C Offline
          Charles Oppermann
          wrote on last edited by
          #24

          I strongly suspect that COM initialization is at issue here[^]. Earlier, I mentioned that COM has to be initialized as follows:

          CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE)

          This is why I think you're new project works and the old one doesn't. Is your old project using multithreaded COM? If so, the calls might fail. [Just saw your other post that resolves your issue. I'm posting this for other people who might encounter ShellExecute problems.]

          /* Charles Oppermann */ http://weblogs.asp.net/chuckop

          A 1 Reply Last reply
          0
          • C Charles Oppermann

            I strongly suspect that COM initialization is at issue here[^]. Earlier, I mentioned that COM has to be initialized as follows:

            CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE)

            This is why I think you're new project works and the old one doesn't. Is your old project using multithreaded COM? If so, the calls might fail. [Just saw your other post that resolves your issue. I'm posting this for other people who might encounter ShellExecute problems.]

            /* Charles Oppermann */ http://weblogs.asp.net/chuckop

            A Offline
            A Offline
            Andraw111
            wrote on last edited by
            #25

            Ok, I will add them, thanks!

            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