Native C ++ development in Windows Mobile and Windows WinCE (Windows Embedded CE), how to retrieve the version information in the resource file

Source: Internet
Author: User
ArticleDirectory
    • 1. Create a new version information item in the resource file.
    • 2. Modify version information as needed
    • 3. added the version fetch function.
    • 4. Retrieve version information

Products developed under Windows Mobile and Windows WinCE (Windows Embedded CE) sometimes need to display the version information of the current product. Generally, the version information is stored in the resource file, for example:

To ensure consistency, all version information should be read from the resource file and not hard code ).

The following describes how to read the version information of a resource file:

1. Create a new version information item in the resource file.

 

2. Modify version information as needed

 

3. added the version fetch function.
Cstring cconfigdialog: getversioninfo (hmodule hlib)
{
Cstring version;
Tchar appfilepath [max_path];
Memset (appfilepath, 0, Sizeof (Char ) * Max_path );
If (Getmodulefilename (hlib, appfilepath, max_path ))
{
DWORD hand = 0;
DWORD verlen = getfileversioninfosize (appfilepath, & hand );
If (0 <verlen)
{
Tchar * verdata = (tchar *) malloc (verlen );
If (Verdata)
{
If (Getfileversioninfow (appfilepath, hand, verlen, verdata ))
{
Vs_fixedfileinfo * verinfo;
Unsigned Buflen;
If (Verqueryvaluew (verdata, _ T ( "\\" ), (Lpvoid *) & verinfo, (puint) & buflen ))
{
Tchar numbtxt [8];
Memset (numbtxt, 0, 8 );
// Major
_ Itow (hiword (verinfo-> dwfileversionms), numbtxt, 10 );
Version = numbtxt;
Version + = _ T ( "." );
// Minor
_ Itow (loword (verinfo-> dwfileversionms), numbtxt, 10 );
Version + = numbtxt;
Version + = _ T ( "." );
// Build
_ Itow (hiword (verinfo-> dwfileversionls), numbtxt, 10 );
Version + = numbtxt;
Version + = _ T ( "." );
// Revision
_ Itow (loword (verinfo-> dwfileversionls), numbtxt, 10 );
Version + = numbtxt;
}
}
Free (verdata );
}
}
}
Return Version;
}

 

4. Retrieve version information
 
Hinstance hinst = (hinstance) hmodule;
Getversioninfo (hinst );

Finished. The effect is as follows:

 

 

I have been developing wtl recently and have written many summary about this. Please refer to my blog.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.