Re: wxEuphoria: wxWidgets_Version() Function?
- Posted by ghaberek (admin) Apr 15, 2015
- 1404 views
Is there a function I can use to determine what version of wxWidgets is being used? I have six PCs (all various flavors of Windows and Office for testing purposes), and I think someone is lagging behind. I need to be able to get the version of wxWidgets, only because I think it would help me debug why delete_tree_item() isn't working.
If I recall correctly, the version information is only exposed via macros so there are not any functions that you could link to dynamically. If you're on Windows, you could try using the GetFileVersionInfo function to determine the library's version. I've wrapped it from memory and available docs, but I don't have the opportunity to test it right now. Good luck!
include std/dll.e include std/machine.e atom Version_dll = open_dll( "Version.dll" ) constant xGetFileVersionInfoSize = define_c_func( Version_dll, "GetFileVersionInfoSizeA", {C_POINTER,C_POINTER}, C_DWORD ) constant xGetFileVersionInfo = define_c_func( Version_dll, "GetFileVersionInfoA", {C_POINTER,C_DWORD,C_DWORD,C_POINTER}, C_BOOL ) constant xVerQueryValue = define_c_func( Version_dll, "VerQueryValueA", {C_POINTER,C_POINTER,C_POINTER,C_POINTER}, C_BOOL ) public function GetFileVersionInfo( sequence filename ) atom lpFilename = allocate_string( filename, 1 ) atom dwLen = c_func( xGetFileVersionInfoSize, {lpFilename,NULL} ) atom lpData = allocate_data( dwLen, 1 ) integer result = c_func( xGetFileVersionInfo, {lpFilename,NULL,dwLen,lpData} ) if result then -- success return lpData end if -- failure return NULL end function public function VerQueryValue( atom info, atom value ) atom pBlock = info atom lpSubBlock = allocate_string( "\\", 1 ) atom lplpBuffer = allocate_data( 4, 1 ) atom puLen = allocate_data( 4, 1 ) integer result = c_func( xVerQueryValue, {pBlock,lpSubBlock,lplpBuffer,puLen} ) if result then -- success atom lpBuffer = peek4u( lplpBuffer ) atom len = peek4u( puLen ) return peek4u( lpBuffer + value ) end if -- failure return {} end function
Example:
include std/convert.e atom info = GetFileVersionInfo( "wxmsw28u_core_gcc_eu.dll" ) if info != NULL then atom lo_dword = VerQueryValue( info, dwFileVersionMS ) atom hi_dword = VerQueryValue( info, dwFileVersionLS ) sequence bytes = int_to_bytes(lo_dword) & int_to_bytes(hi_dword) atom major = bytes_to_int( bytes[3..4] ) -- 2 atom minor = bytes_to_int( bytes[1..2] ) -- 8 atom patch = bytes_to_int( bytes[7..8] ) -- 12 printf( 1, "wxWidgets %d.%d.%d\n", {major,minor,patch} ) -- prints "wxWidgets 2.8.12" end if
Edit:
I had some time to test this and of course it was wrong. Updated VerQueryValue function and example code. I tested against the same DLLs that you should be using from the 0.17.0 package I've provided.
-Greg