Jump to content
Sign in to follow this  

Retrieve language info from file

Recommended Posts


I am trying to retrieve the language info from a dll file similar to the way a files version is retrieved using FileGetVersion. I can see the info I want on the version tab of the file but I am unable to read it via AutoIt.

I have need to read the \VarFileInfo\Translation block of the files resource data to get the decimal for the language I can then use it to change to the language locale but I don't know how to do it. Windows obviously does it so it maybe an API call as it also converts it to the locale.

Does anyone know how to do this?.


Share this post

Link to post
Share on other sites

Have you tried FileGetVersion("your.dll", "DefaultLangCodepage") ?

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post

Link to post
Share on other sites

Have you tried FileGetVersion("your.dll", "DefaultLangCodepage") ?

Damn that was fast :-). I hadn't tried it but I have now and it works, I have looked at the FilegetVersion help section a few times but always missed the special strings, thanks SKruge

Share this post

Link to post
Share on other sites

If your trying to see what languages a resource type in a dll contains (eg: RT_ICON, RT_FONT, $RT_STRING .. etc)

Then you can use EnumResourceLanguages() or EnumResourceLanguagesEx().

#include <WinAPI.au3>

Global Const $RT_CURSOR = 1
Global Const $RT_BITMAP = 2
Global Const $RT_ICON = 3
Global Const $RT_MENU = 4
Global Const $RT_DIALOG = 5
Global Const $RT_STRING = 6
Global Const $RT_FONTDIR = 7
Global Const $RT_FONT = 8
Global Const $RT_ACCELERATOR = 9
Global Const $RT_RCDATA = 10
Global Const $RT_MESSAGETABLE = 11
Global Const $RT_GROUP_CURSOR = 12
Global Const $RT_GROUP_ICON = 14
Global Const $RT_VERSION = 16
Global Const $RT_DLGINCLUDE = 17
Global Const $RT_PLUGPLAY = 19
Global Const $RT_VXD = 20
Global Const $RT_ANICURSOR = 21
Global Const $RT_ANIICON = 22
Global Const $RT_HTML = 23
Global Const $RT_MANIFEST = 24

$hModule = _WinAPI_LoadLibrary("shell32.dll")
_EnumResourceLanguages($hModule, $RT_VERSION, 1)

Func _EnumResourceLanguages($hModule, $pType, $pName)
    Local $aRet, $xCB
    If Not IsPtr($hModule) Then Return SetError(1, 0, 0)
    $xCB = DllCallbackRegister('___EnumResLangProc', 'int', 'int_ptr;int_ptr;int_ptr;int_ptr;int_ptr')
    $aRet = DllCall('kernel32.dll', 'int', 'EnumResourceLanguagesW', 'ptr', $hModule, 'int', $pType, 'int', $pName, 'ptr', DllCallbackGetPtr($xCB), 'ptr', 0)
    If $aRet[0] <> 1 Then Return SetError(2, 0, 0)
    Return SetError(0, 0, 1)

Func ___EnumResLangProc($hModule, $pType, $pName, $wIDLanguage, $lParam)
    Local $aSize = DllCall('kernel32.dll', 'int', 'GlobalSize', 'ptr', $wIDLanguage)
    ConsoleWrite($wIDLanguage & @LF)
    Return 1

If you need to find what resource types are in the file then you can use EnumResourceTypes() or EnumResourceTypesEx().

If you need to find out what resource names are in the file then you can use EnumResourceNames() or EnumResourceNamesEx().

More info on Resource functions here MSDN


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this