LabWindows/CVI User Group Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Sugested new feature for LabWindows

Yes, that makes sense.

Luis

0 Kudos
Message 11 of 12
(1,084 Views)

Actually informations on the application can be obtained directly from the exe file, at least on Windows OS. Informations stored in Build >> Current settings >> Version info panel are stored in the compiled application and can be retrieved with some API calls: the following retrieves the "Product version" string stored in that panel.

    char    a[50], msg[128], file[MAX_PATHNAME_LEN], langName[16];
    UINT    len;
    DWORD   infoSize;
    DWORD   uselessParm;
    DWORD*  tempDWORD;

    GetProjectDir (file);
    MakePathname (file, pgm, file);   // Application pathname
    if (!(infoSize = GetFileVersionInfoSize (file, &uselessParm)))
        goto view;
    versionInfo = malloc (infoSize);
    if (versionInfo) {
        if (!GetFileVersionInfo (file, 0, infoSize, versionInfo))
            goto view;

        /* Get the Language and Code Page                                        */
        /*     The below 'hex' value looks a little confusing, but essentially   */
        /*     it is the hexidecimal representation of a couple different values */
        /*     that represent the language and character set that we are wanting */
        /*     string values for.  040904E4 is very common, it means:            */
        /*         US English, Windows MultiLingual characterset -- or:          */
        /*         04------    = SUBLANG_ENGLISH_USA                             */
        /*         --09----    = LANG_ENGLISH                                    */
        /*         --11----    = LANG_JAPANESE                                   */
        /*         ----04E4    = 1252 = Codepage for Windows:Multilingual        */
        if (VerQueryValue (versionInfo, TEXT("\\VarFileInfo\\Translation"),
                       ((void **)(&tempDWORD)), &len)) {

            /* lVerPointer is a pointer to four 4 bytes of Hex number, first two */
            /* bytes are language id, and last two bytes are code page. However, */
            /* Lang_Charset_String needs a string of 4 hex digits, the first two */
            /* characters correspond to the language id and last two the last two*/
            /* character correspond to the code page id.                         */             
            langName[0] = 0;
            sprintf (langName, "%04hX%04hX", LOWORD (*tempDWORD),
                     HIWORD (*tempDWORD));
            if (langName[0]) {
                sprintf (msg, "\\StringFileInfo\\%s\\ProductVersion", langName);
                if (!VerQueryValue (versionInfo, TEXT (msg), &tempBuffer, &len) == 0)
                if (tempBuffer)
                    SetCtrlVal (panelHandle, PANEL_VERSION, (char*)tempBuffer);    // Show program version
            }
        }
    }

For this to work you need to add version.lib to the project and #include <windows.h> (or at least winver.h: possibly some file more, I don't know)

Tip1: program filename is received by the Main () function in argv[0].

Tip2: do not forget to append a "+" to version fields you want to be incremented on each compilation



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 12 of 12
(1,084 Views)