Projektversion auslesen



  • Hallo,
    man kann in den Projekteigenschaften eine Versionsnummer vergeben.
    Kann ich die im Programm irgendwie auslesen?



  • Ja du kannst alle Informationen einer EXE auch der grade gestarteten auslesen.

    DWORD handle; //only a dummy
    	DWORD size;
    
    	String slExeName = Application->ExeName;
    
    	size = GetFileVersionInfoSize(slExeName.w_str(), &handle);
    
    	if(size == 0) return; // No file information
    
    	wchar_t *buffer = new wchar_t [size];
    	bool status = GetFileVersionInfo(slExeName.w_str(), 0, size, buffer);
    	if(!status) {
    		delete [] buffer;
    		return;
    	}
    
    	// Extract the language ID
    	UINT datasize;
    	unsigned short *translation;
    
    	/*status =*/ VerQueryValue( buffer, L"\\VarFileInfo\\Translation",
    	(void **) &translation, &datasize);
    
    	// Here we create a prefix string that is the same for all the keys.
    	String prefix = "\\StringFileInfo\\" + String::IntToHex(translation [0], 4) + String::IntToHex(translation [1], 4);
    
    	// Extract all the version information.
    	String company_name         = GetVersionKey(buffer, prefix, L"CompanyName");
    	String file_description     = GetVersionKey(buffer, prefix, L"FileDescription");
    	String file_version         = GetVersionKey(buffer, prefix, L"FileVersion");
    	String internal_name        = GetVersionKey(buffer, prefix, L"InternalName");
    	String legal_copyright      = GetVersionKey(buffer, prefix, L"LegalCopyright");
    	String legal_trademarks     = GetVersionKey(buffer, prefix, L"LegalTrademarks");
    	String original_filename    = GetVersionKey(buffer, prefix, L"OriginalFilename");
    	String product_name         = GetVersionKey(buffer, prefix, L"ProductName");
    	String product_version      = GetVersionKey(buffer, prefix, L"ProductVersion");
    	String file_comments        = GetVersionKey(buffer, prefix, L"Comments");
    	delete [] buffer;
    

Log in to reply