LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

DLL Version Information in CVI-RT

Is there a way to obtain version information of DLL's in CVI-RT?  The supported WIN32 API functions does not appear to include the following functions:

 

- GetFileVersionInfoSize()

- GetFileVersionInfo()

 

 

0 Kudos
Message 1 of 4
(3,590 Views)

Hello tedoyle,

 

If you are just interested in getting the file version information, you could try the following (error checking omitted for brevity): 

 

 

void CVIFUNC_C RTmain (void)

{

    char *              fileInfo;

    char *              lock; 

    int                 size = 0;

    HMODULE             module = 0;

    HRSRC               resource;

    HRSRC               loaded;

    VS_FIXEDFILEINFO *  pFFI; 

    

    if (InitCVIRTE (0, 0, 0) == 0)

        return;    /* out of memory */


    Cls();

    printf("\n\n\n\n\n");

    

    module = LoadLibraryEx("c:\\ni-rt\\system\\cvi_lvrt.dll", NULL, DONT_RESOLVE_DLL_REFERENCES);

    resource = FindResource (module, MAKEINTRESOURCE(1), RT_VERSION);

    loaded = LoadResource (module, resource);

    lock = LockResource (loaded);

    

    size = SizeofResource(module, resource);

    fileInfo = malloc(size);

    memcpy(fileInfo, lock, size);


    pFFI = (VS_FIXEDFILEINFO *)((DWORD *) fileInfo + 10);


    printf("\nThe version of cvi_lvrt is %d.%d.%d.%d\n\n",

            HIWORD(pFFI->dwFileVersionMS),

            LOWORD(pFFI->dwFileVersionMS),

            HIWORD(pFFI->dwFileVersionLS),

            LOWORD(pFFI->dwFileVersionLS));

    

    if (fileInfo)

        free(fileInfo);

    if (module)

        FreeLibrary(module);


    CloseCVIRTE ();     

}

 

 

Let me know if you have any questions

 

NickB

National Instruments  

0 Kudos
Message 2 of 4
(3,555 Views)
Thanks for the information.  The example seems to work with LabWindows generated DLL's.  However, it did not work with a DLL generated under VS2005.  The FindResource() function failed.  I didn't dig into the reason.  Will probably look into this in more detail tomorrow.  Anyway, thanks again for the reply!
0 Kudos
Message 3 of 4
(3,537 Views)

under Visual Studio, the generated executable does not have a Version resource by default. you have to add it yourself.

 

this is very easy to accomplish: on the solution explorer tab, right click on your project and select "Add/Resource...". in the dialog box which appears, select "Version". now go to the Resource View and edit the version resource. don't forget to frequently set a new version number for your executable. (i don't know any way to automatically increment the version number).

0 Kudos
Message 4 of 4
(3,517 Views)