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. Using GetOpenFileName on both Win98 and WinXP

Using GetOpenFileName on both Win98 and WinXP

Scheduled Pinned Locked Moved C / C++ / MFC
jsonhelpquestion
7 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.
  • P Offline
    P Offline
    Patcher32
    wrote on last edited by
    #1

    GetOpenFileName() is Win32 API function which accepts a pointer to a OPENFILENAME structure. In this structure, you have to set up a member lStructSize to sizeof(OPENFILENAME) for Windows XP and above. But for Windows98 it must be OPENFILENAME_SIZE_VERSION_400. When I use an if statement to do it, compiler gives fatal error and stops :

    OPENFILENAME ofn;
    if(win98()==FALSE)
    ofn.lStructSize = sizeof(OPENFILENAME); //for Windows XP
    else
    ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; //for Windows 98/ME

    Ofcourse I can make seperate functions for opening files in win98 etc. But what is a better way to do this. Thank you

    _ L 2 Replies Last reply
    0
    • P Patcher32

      GetOpenFileName() is Win32 API function which accepts a pointer to a OPENFILENAME structure. In this structure, you have to set up a member lStructSize to sizeof(OPENFILENAME) for Windows XP and above. But for Windows98 it must be OPENFILENAME_SIZE_VERSION_400. When I use an if statement to do it, compiler gives fatal error and stops :

      OPENFILENAME ofn;
      if(win98()==FALSE)
      ofn.lStructSize = sizeof(OPENFILENAME); //for Windows XP
      else
      ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; //for Windows 98/ME

      Ofcourse I can make seperate functions for opening files in win98 etc. But what is a better way to do this. Thank you

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      What is the error that you get?

      «_Superman_» I love work. It gives me something to do between weekends.
      Microsoft MVP (Visual C++)

      P 1 Reply Last reply
      0
      • _ _Superman_

        What is the error that you get?

        «_Superman_» I love work. It gives me something to do between weekends.
        Microsoft MVP (Visual C++)

        P Offline
        P Offline
        Patcher32
        wrote on last edited by
        #3

        This is what Pelles C Compiler displays : Building MAIN.obj. C:\Code\Hasher\MAIN.C(34): fatal error: Internal error: get_rule(). *** Error code: 1 *** Done.

        _ 1 Reply Last reply
        0
        • P Patcher32

          This is what Pelles C Compiler displays : Building MAIN.obj. C:\Code\Hasher\MAIN.C(34): fatal error: Internal error: get_rule(). *** Error code: 1 *** Done.

          _ Offline
          _ Offline
          _Superman_
          wrote on last edited by
          #4

          From the code that you pasted, I'm not able to figure out what the problem is. The if condition looks perfect. Is that on line 34 of main.c?

          «_Superman_» I love work. It gives me something to do between weekends.
          Microsoft MVP (Visual C++)

          P 1 Reply Last reply
          0
          • _ _Superman_

            From the code that you pasted, I'm not able to figure out what the problem is. The if condition looks perfect. Is that on line 34 of main.c?

            «_Superman_» I love work. It gives me something to do between weekends.
            Microsoft MVP (Visual C++)

            P Offline
            P Offline
            Patcher32
            wrote on last edited by
            #5

            Yes. Its line # 34 in main.c When I remove if statement and just set lStructSize to one of the values, the code compiles perfectly.

            O 1 Reply Last reply
            0
            • P Patcher32

              Yes. Its line # 34 in main.c When I remove if statement and just set lStructSize to one of the values, the code compiles perfectly.

              O Offline
              O Offline
              Ozer Karaagac
              wrote on last edited by
              #6

              It seems that there is nothing unusual. Give it a try by changing the name of the function "win98". It might confuse the compiler? :)

              1 Reply Last reply
              0
              • P Patcher32

                GetOpenFileName() is Win32 API function which accepts a pointer to a OPENFILENAME structure. In this structure, you have to set up a member lStructSize to sizeof(OPENFILENAME) for Windows XP and above. But for Windows98 it must be OPENFILENAME_SIZE_VERSION_400. When I use an if statement to do it, compiler gives fatal error and stops :

                OPENFILENAME ofn;
                if(win98()==FALSE)
                ofn.lStructSize = sizeof(OPENFILENAME); //for Windows XP
                else
                ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; //for Windows 98/ME

                Ofcourse I can make seperate functions for opening files in win98 etc. But what is a better way to do this. Thank you

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

                What does the win98() function do?

                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