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. how to extract "versioninfo" from sourcecode?

how to extract "versioninfo" from sourcecode?

Scheduled Pinned Locked Moved C / C++ / MFC
questionvisual-studiographicsjsonhelp
3 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.
  • R Offline
    R Offline
    rolfhorror
    wrote on last edited by
    #1

    i have the following code, it compiles without error, but how can i extract this into a global CString that i can use later for ie in an messagebox or something? i've tried several names in the code but i cant get a hold of them.. //the code string FixedModuleVersion() { char file_name[ MAX_PATH ]; GetModuleFileName( ::GetModuleHandle( NULL ), file_name, MAX_PATH ); DWORD dwDummyHandle; DWORD len = GetFileVersionInfoSize( file_name, &dwDummyHandle ); vector buf( len ); ::GetFileVersionInfo( file_name, 0, len, buf.begin() ); unsigned int ver_length; LPVOID lpvi; ::VerQueryValue( buf.begin(), "\\", &lpvi, &ver_length ); VS_FIXEDFILEINFO fileInfo; fileInfo = *(VS_FIXEDFILEINFO*)lpvi; stringstream s; s <<HIWORD(fileInfo.dwFileVersionMS) <<"." <<LOWORD(fileInfo.dwFileVersionMS) <<"." <<HIWORD(fileInfo.dwFileVersionLS) <<"." <<LOWORD(fileInfo.dwFileVersionLS); return s.str(); } // // This routine will extract the version string from the // string version resource in the RC file for the current module. // Note that you must add version.lib to your project to // link to the Win32 versioning API calls. The actual call // VerQueryValue() uses a value of 040904B0 for the language // and character set. This value is equivalent to English // language text encoded using Unicode. // string StringModuleVersion() { char file_name[ MAX_PATH ]; GetModuleFileName( ::GetModuleHandle( NULL ), file_name, MAX_PATH ); DWORD dwDummyHandle; DWORD len = GetFileVersionInfoSize( file_name, &dwDummyHandle ); vector buf( len ); ::GetFileVersionInfo( file_name, 0, len, buf.begin() ); char *version; unsigned int ver_length; ::VerQueryValue( buf.begin(), "\\StringFileInfo\\040904B0\\FileVersion", (void **) &version, &ver_length ); return string( version, ver_length ); } //end - now how to get hold of something to use?

    stefanmihaimogaS 1 Reply Last reply
    0
    • R rolfhorror

      i have the following code, it compiles without error, but how can i extract this into a global CString that i can use later for ie in an messagebox or something? i've tried several names in the code but i cant get a hold of them.. //the code string FixedModuleVersion() { char file_name[ MAX_PATH ]; GetModuleFileName( ::GetModuleHandle( NULL ), file_name, MAX_PATH ); DWORD dwDummyHandle; DWORD len = GetFileVersionInfoSize( file_name, &dwDummyHandle ); vector buf( len ); ::GetFileVersionInfo( file_name, 0, len, buf.begin() ); unsigned int ver_length; LPVOID lpvi; ::VerQueryValue( buf.begin(), "\\", &lpvi, &ver_length ); VS_FIXEDFILEINFO fileInfo; fileInfo = *(VS_FIXEDFILEINFO*)lpvi; stringstream s; s <<HIWORD(fileInfo.dwFileVersionMS) <<"." <<LOWORD(fileInfo.dwFileVersionMS) <<"." <<HIWORD(fileInfo.dwFileVersionLS) <<"." <<LOWORD(fileInfo.dwFileVersionLS); return s.str(); } // // This routine will extract the version string from the // string version resource in the RC file for the current module. // Note that you must add version.lib to your project to // link to the Win32 versioning API calls. The actual call // VerQueryValue() uses a value of 040904B0 for the language // and character set. This value is equivalent to English // language text encoded using Unicode. // string StringModuleVersion() { char file_name[ MAX_PATH ]; GetModuleFileName( ::GetModuleHandle( NULL ), file_name, MAX_PATH ); DWORD dwDummyHandle; DWORD len = GetFileVersionInfoSize( file_name, &dwDummyHandle ); vector buf( len ); ::GetFileVersionInfo( file_name, 0, len, buf.begin() ); char *version; unsigned int ver_length; ::VerQueryValue( buf.begin(), "\\StringFileInfo\\040904B0\\FileVersion", (void **) &version, &ver_length ); return string( version, ver_length ); } //end - now how to get hold of something to use?

      stefanmihaimogaS Offline
      stefanmihaimogaS Offline
      stefanmihaimoga
      wrote on last edited by
      #2

      Hello, One of these articles should help you: 1) Sven Wiegand's CFileVersionInfo[^] class 2) Eran Yariv, Kenneth Lea's DLL Version[^] 3) Armen Hakobyan's CFileVersionInfo[^] class Best regards, Mihai Moga

      R 1 Reply Last reply
      0
      • stefanmihaimogaS stefanmihaimoga

        Hello, One of these articles should help you: 1) Sven Wiegand's CFileVersionInfo[^] class 2) Eran Yariv, Kenneth Lea's DLL Version[^] 3) Armen Hakobyan's CFileVersionInfo[^] class Best regards, Mihai Moga

        R Offline
        R Offline
        rolfhorror
        wrote on last edited by
        #3

        never mind i got it working thx

        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