Gets the program compile time, which is used to generate version numbers automatically

Source: Internet
Author: User

We write software, always want to change the program can automatically generate version number, do not manually to change, so much convenient ah. The VS compiler can implement this functionality. As shown below:




/* Get program compile time to generate version number automatically __date__ "2013" "Mar 1 2013" __time__ "21:42:20" * * void Getprogramcompiletime (	
	SYSTEMTIME &st) {TCHAR szdate[20];
	ZeroMemory (szdate, sizeof (szdate));
	ZeroMemory (&st, sizeof (SYSTEMTIME));
	
	_stprintf (Szdate, TEXT ("%s"), __date__);
	
	St.wyear = _tcstoul (szdate+7, 0, 10);
	St.wday = szdate[5]-TEXT (' 0 ');
	if (Szdate[4]!= text (")" {st.wday + = (szdate[4]-text (' 0 ')) * 10;
			Switch (szdate[0]) {case TEXT (' A '): if (szdate[1] = = TEXT (' P ')) {st.wmonth = 4;
			else {st.wmonth = 8;
			
		} break;
			Case TEXT (' D '): St.wmonth = 12;
			
		Break
			Case TEXT (' F '): St.wmonth = 2;
			
		Break
			Case TEXT (' J '): if (szdate[1] = = TEXT (' a ')) {st.wmonth = 1;
				else {if (szdate[2] = = TEXT (' n ')) {st.wmonth = 6;
				else {st.wmonth = 7;
			
		}} break;
			Case TEXT (' M '): if (szdate[2] = = TEXT (' r ')) {st.wmonth = 3;
			} else{st.wmonth = 5;
			
		} break;
			Case TEXT (' N '): St.wmonth = 11;
			
		Break
			Case TEXT (' O '): St.wmonth = 10;
			
		Break
			Case TEXT (' S '): St.wmonth = 9;
	Break
	} zeromemory (szdate, sizeof (szdate));
	
	sprintf (Szdate, TEXT ("%s"), __time__);	
	St.whour = (szdate[0]-text (' 0 ')) * + (Szdate[1]-TEXT (' 0 '));
	St.wminute = (szdate[3]-text (' 0 ')) * + (Szdate[4]-TEXT (' 0 '));
	St.wsecond = (Szdate[6]-text (' 0 ')) * + (Szdate[7]-TEXT (' 0 '));
Return }

Getprogramcompiletime This function to get the compile time out and save it in a SYSTEMTIME structure so that it can be used casually.

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.