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. wsprintf in 32 and 64 bit windows.

wsprintf in 32 and 64 bit windows.

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpannouncement
9 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.
  • J Offline
    J Offline
    Johan Bertilsdotter
    wrote on last edited by
    #1

    CFileVersionInfo fvi;
    char szVer[ 512 ] = { 0 };
    if( fvi.Open( _T( "Econovent.dll" )))
    {
    ::wsprintf( szVer,
    _T( "%d.%d.%d.%d" ),
    fvi.GetFileVersionMajor(), // Major version
    fvi.GetFileVersionMinor(), // Minor version
    fvi.GetFileVersionBuild(), // Build number
    fvi.GetFileVersionQFE() // QFE
    );
    fvi.Close();}

    It works perfect in win32, But when complied in x64 the "wsprintf", stops working. Are the a better solution that works in x64 and win32 at the same time. I understand that i have change. I have tried but then its not working in win32 mode. The code need to be old C-style version. I'm not native C/C++ i'm just trying to fixa a "bug".

    L L J C 5 Replies Last reply
    0
    • J Johan Bertilsdotter

      CFileVersionInfo fvi;
      char szVer[ 512 ] = { 0 };
      if( fvi.Open( _T( "Econovent.dll" )))
      {
      ::wsprintf( szVer,
      _T( "%d.%d.%d.%d" ),
      fvi.GetFileVersionMajor(), // Major version
      fvi.GetFileVersionMinor(), // Minor version
      fvi.GetFileVersionBuild(), // Build number
      fvi.GetFileVersionQFE() // QFE
      );
      fvi.Close();}

      It works perfect in win32, But when complied in x64 the "wsprintf", stops working. Are the a better solution that works in x64 and win32 at the same time. I understand that i have change. I have tried but then its not working in win32 mode. The code need to be old C-style version. I'm not native C/C++ i'm just trying to fixa a "bug".

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

      jn4u@msn.com wrote:

      the "wsprintf", stops working.

      You need to provide some more information, as this does not give any clues as to what may be happening. Try using your debugger to step through your code and see exactly what values are being returned from the function calls.

      Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness

      1 Reply Last reply
      0
      • J Johan Bertilsdotter

        CFileVersionInfo fvi;
        char szVer[ 512 ] = { 0 };
        if( fvi.Open( _T( "Econovent.dll" )))
        {
        ::wsprintf( szVer,
        _T( "%d.%d.%d.%d" ),
        fvi.GetFileVersionMajor(), // Major version
        fvi.GetFileVersionMinor(), // Minor version
        fvi.GetFileVersionBuild(), // Build number
        fvi.GetFileVersionQFE() // QFE
        );
        fvi.Close();}

        It works perfect in win32, But when complied in x64 the "wsprintf", stops working. Are the a better solution that works in x64 and win32 at the same time. I understand that i have change. I have tried but then its not working in win32 mode. The code need to be old C-style version. I'm not native C/C++ i'm just trying to fixa a "bug".

        L Offline
        L Offline
        Lakamraju Raghuram
        wrote on last edited by
        #3

        Use

        GetLastError()

        method after you called wsprintf and provide the error code

        1 Reply Last reply
        0
        • J Johan Bertilsdotter

          CFileVersionInfo fvi;
          char szVer[ 512 ] = { 0 };
          if( fvi.Open( _T( "Econovent.dll" )))
          {
          ::wsprintf( szVer,
          _T( "%d.%d.%d.%d" ),
          fvi.GetFileVersionMajor(), // Major version
          fvi.GetFileVersionMinor(), // Minor version
          fvi.GetFileVersionBuild(), // Build number
          fvi.GetFileVersionQFE() // QFE
          );
          fvi.Close();}

          It works perfect in win32, But when complied in x64 the "wsprintf", stops working. Are the a better solution that works in x64 and win32 at the same time. I understand that i have change. I have tried but then its not working in win32 mode. The code need to be old C-style version. I'm not native C/C++ i'm just trying to fixa a "bug".

          J Offline
          J Offline
          Johan Bertilsdotter
          wrote on last edited by
          #4

          When compling in platform win32 works. Whan compile in x64. cannot convert parameter 1 from 'char [512]' to 'LPWSTR' in the wsprintf call first parameter szVer. Understand that de definition "change" för char in the call or I have tride windhows.h and TCHAR.

          1 Reply Last reply
          0
          • J Johan Bertilsdotter

            CFileVersionInfo fvi;
            char szVer[ 512 ] = { 0 };
            if( fvi.Open( _T( "Econovent.dll" )))
            {
            ::wsprintf( szVer,
            _T( "%d.%d.%d.%d" ),
            fvi.GetFileVersionMajor(), // Major version
            fvi.GetFileVersionMinor(), // Minor version
            fvi.GetFileVersionBuild(), // Build number
            fvi.GetFileVersionQFE() // QFE
            );
            fvi.Close();}

            It works perfect in win32, But when complied in x64 the "wsprintf", stops working. Are the a better solution that works in x64 and win32 at the same time. I understand that i have change. I have tried but then its not working in win32 mode. The code need to be old C-style version. I'm not native C/C++ i'm just trying to fixa a "bug".

            C Offline
            C Offline
            Chris Losinger
            wrote on last edited by
            #5

            check your build settings. you probably have "Multi-byte" or "Unicode" set for "Character set" on the x64 build, but "not set" on the x86 build.

            image processing toolkits | batch image processing

            J 1 Reply Last reply
            0
            • J Johan Bertilsdotter

              CFileVersionInfo fvi;
              char szVer[ 512 ] = { 0 };
              if( fvi.Open( _T( "Econovent.dll" )))
              {
              ::wsprintf( szVer,
              _T( "%d.%d.%d.%d" ),
              fvi.GetFileVersionMajor(), // Major version
              fvi.GetFileVersionMinor(), // Minor version
              fvi.GetFileVersionBuild(), // Build number
              fvi.GetFileVersionQFE() // QFE
              );
              fvi.Close();}

              It works perfect in win32, But when complied in x64 the "wsprintf", stops working. Are the a better solution that works in x64 and win32 at the same time. I understand that i have change. I have tried but then its not working in win32 mode. The code need to be old C-style version. I'm not native C/C++ i'm just trying to fixa a "bug".

              J Offline
              J Offline
              Johan Bertilsdotter
              wrote on last edited by
              #6

              Can i change the code copy to the szVer in a better way that does not use wsprint. Just want the format. xx.xx.xx.xx

              L 1 Reply Last reply
              0
              • C Chris Losinger

                check your build settings. you probably have "Multi-byte" or "Unicode" set for "Character set" on the x64 build, but "not set" on the x86 build.

                image processing toolkits | batch image processing

                J Offline
                J Offline
                Johan Bertilsdotter
                wrote on last edited by
                #7

                Thank you. I missed that on my project. It’s work perfect. Some of my collage at work pointed out that change to “std::string” in the project. But still the interface to dll need to be native C with c-style string. Is std::string more neutral to the character set? Comming from Delphi to C# world then C/C++ for this project lot of reading "new" things. My old Charles Petzold book is back on the self again. ;D

                C 1 Reply Last reply
                0
                • J Johan Bertilsdotter

                  Can i change the code copy to the szVer in a better way that does not use wsprint. Just want the format. xx.xx.xx.xx

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

                  You should use TCHAR for your array and _stprintf() to fill it. In that way you can compile for ANSI or Unicode without the need to change your source.

                  Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness

                  1 Reply Last reply
                  0
                  • J Johan Bertilsdotter

                    Thank you. I missed that on my project. It’s work perfect. Some of my collage at work pointed out that change to “std::string” in the project. But still the interface to dll need to be native C with c-style string. Is std::string more neutral to the character set? Comming from Delphi to C# world then C/C++ for this project lot of reading "new" things. My old Charles Petzold book is back on the self again. ;D

                    C Offline
                    C Offline
                    Chris Losinger
                    wrote on last edited by
                    #9

                    jn4u wrote:

                    Is std::string more neutral to the character set?

                    sadly, no. there is a std::wstring variation to handle wide char strings.

                    image processing toolkits | batch image processing

                    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