#include <version_checker.h>
Inheritance diagram for version_checker:


Public Member Functions | |
| version_checker (const istring &library_file_name, const version &expected, const istring &version_complaint) | |
| Constructs a checking object and ensures the version is appropriate. | |
| virtual | ~version_checker () |
| Destructor releases any resources. | |
| bool | good_version () const |
| Performs the actual version check. | |
| IMPLEMENT_CLASS_NAME ("version_checker") | |
| istring | text_form () const |
| Provides a text view of all the important info owned by this object. | |
| void | complain_wrong_version (const istring &library_file_name, const version &expected_version, const version &version_found) const |
| Reports that the file has the wrong version. | |
| void | complain_cannot_load (const istring &library_file_name) const |
| Reports that the dll could not be loaded. | |
Static Public Member Functions | |
| static bool | loaded (const istring &library_file_name) |
| returns true if the "library_file_name" is currently loaded. | |
| static void * | get_handle (const istring &library_file_name) |
| retrieves the module handle for the "library_file_name". | |
| static istring | get_name (void *to_find) |
| returns the name of the HMODULE specified by "to_find". | |
| static version | get_version (const istring &pathname) |
| Returns the version given a "pathname" to the DLL or EXE file. | |
| static bool | get_record (const istring &pathname, version_record &to_fill) |
| Retrieves a version record for the file at "pathname". | |
| static bool | retrieve_version_info (const istring &filename, byte_array &to_fill) |
| Retrieves the version info for the "filename" into the array "to_fill". | |
| static bool | get_language (byte_array &version_chunk, u_short &high, u_short &low) |
| Gets the language identifier out of the "version_chunk". | |
Definition at line 27 of file version_checker.h.
| version_checker::version_checker | ( | const istring & | library_file_name, | |
| const version & | expected, | |||
| const istring & | version_complaint | |||
| ) |
Constructs a checking object and ensures the version is appropriate.
the version checking (a call to the good_version() function) will succeed if the library with the "library_file_name" (such as "basis32.dll") has the "expected" version. the simplest way to check if the version is correct is probably similar to:
if (!version_checker("my.dll", version(1.2.3.4)).good_version()) { ...program exit or version failure management... }
istring version_grievance = "Please contact Floobert Corporation for " "the latest DLL and Executable files (http://www.floobert.com).";
Definition at line 53 of file version_checker.cpp.
| version_checker::~version_checker | ( | ) | [virtual] |
Destructor releases any resources.
Definition at line 60 of file version_checker.cpp.
References WHACK().
| bool version_checker::good_version | ( | ) | const |
Performs the actual version check.
If the version check is unsuccessful, then a message that describes the problem is shown to the user and false is returned. NOTE: the version check will also fail if the version information structure cannot be found for that library.
Definition at line 74 of file version_checker.cpp.
References version::compatible(), complain_wrong_version(), portable::env_string(), get_version(), and istring::s().
| version_checker::IMPLEMENT_CLASS_NAME | ( | "version_checker" | ) |
| istring version_checker::text_form | ( | ) | const [virtual] |
Provides a text view of all the important info owned by this object.
It is understood that there could be a large amount of information and that this function might take a relatively long time to complete. The information can be provided in multiple lines if desired (it is good to use log_base::platform_ending() for the line breaks to help to ensure that the text is formatted appropriately). the default is quite lame and should be overridden.
Reimplemented from object_base.
Definition at line 67 of file version_checker.cpp.
References object_base::class_name(), and version::text_form().
| bool version_checker::loaded | ( | const istring & | library_file_name | ) | [static] |
returns true if the "library_file_name" is currently loaded.
Definition at line 91 of file version_checker.cpp.
References get_handle(), and istring::t().
| void * version_checker::get_handle | ( | const istring & | library_file_name | ) | [static] |
retrieves the module handle for the "library_file_name".
This returns zero if the library cannot be located. the returned pointer wraps a win32 HMODULE currently, or it is meaningless.
Definition at line 101 of file version_checker.cpp.
References istring::t().
Referenced by loaded().
| istring version_checker::get_name | ( | void * | to_find | ) | [static] |
returns the name of the HMODULE specified by "to_find".
If that handle cannot be located, then an empty string is returned.
Definition at line 111 of file version_checker.cpp.
References portable::module_name().
Referenced by complain_wrong_version().
Returns the version given a "pathname" to the DLL or EXE file.
If the directory component is not included, then the search path will be used.
Definition at line 166 of file version_checker.cpp.
References __build_FILE_VERSION, array< contents >::access(), version::from_text(), get_language(), istring::length(), NIL, retrieve_version_info(), istring::SPRINTF, and istring::zap().
Referenced by good_version(), and main().
| bool version_checker::get_record | ( | const istring & | pathname, | |
| version_record & | to_fill | |||
| ) | [static] |
Retrieves a version record for the file at "pathname".
Returns the full version record found for a given "pathname" to the DLL or EXE file in the record "to_fill". if the directory component of the path is not included, then the search path will be used. false is returned if some piece of information could not be located; this does not necessarily indicate a total failure of the retrieval.
Definition at line 217 of file version_checker.cpp.
References array< contents >::access(), version_record::company_name, version_record::copyright, version_record::description, version_record::file_version, version::from_text(), get_language(), version_record::internal_name, NIL, version_record::original_name, version_record::product_name, version_record::product_version, retrieve_version_info(), istring::SPRINTF, and version_record::trademarks.
| bool version_checker::retrieve_version_info | ( | const istring & | filename, | |
| byte_array & | to_fill | |||
| ) | [static] |
Retrieves the version info for the "filename" into the array "to_fill".
Definition at line 114 of file version_checker.cpp.
References array< contents >::access(), array< contents >::reset(), and istring::t().
Referenced by get_record(), and get_version().
| bool version_checker::get_language | ( | byte_array & | version_chunk, | |
| u_short & | high, | |||
| u_short & | low | |||
| ) | [static] |
Gets the language identifier out of the "version_chunk".
Returns true if the language identifier for the dll's version chunk could be stored in "high" and "low". This is a win32-only method.
Definition at line 141 of file version_checker.cpp.
References array< contents >::access(), and array< contents >::length().
Referenced by get_record(), and get_version().
| void version_checker::complain_wrong_version | ( | const istring & | library_file_name, | |
| const version & | expected_version, | |||
| const version & | version_found | |||
| ) | const |
Reports that the file has the wrong version.
Definition at line 310 of file version_checker.cpp.
References continuable_error, version::DOTS, version::flex_text_form(), GET_INSTANCE_HANDLE, get_name(), portable::module_name(), and istring::s().
Referenced by good_version().
| void version_checker::complain_cannot_load | ( | const istring & | library_file_name | ) | const |
Reports that the dll could not be loaded.
Definition at line 337 of file version_checker.cpp.
References continuable_error, and istring::s().
1.5.1