WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Language Vers - Regional Settings

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

How to Get OS Language

Keywords: 	 OS language

Question:

I'm still having a problem finding out what language the OS is so I can finish the installs for IE5 I have tried using some sample code from your Web site and it works but the value returned is a user setting and not the true OS language i.e. result = DllCall(Kernel, long:"GetLocaleInfoA", long:GetLocale, long:LOCALE_SLONGDATE, lpbinary:lpLCData, long:cchData)

I was looking up a few Win32 API's functions and then found this article

HOWTO: Determine Default Language ID of Windows 95 or WinNT  
http://support.microsoft.com/support/kb/articles/Q181/6/04.ASP
I then made this code to see what I would get however it returns really nothing ( I think its the way I did the calls) I talked to Microsoft directly on how to get the OS language and they suggested doing the type of calls but rewrite my code using Windows Scripting Host!!! (Now I don't want that to happen and nor does your company)

Thanks again

Answer:

The easy way...
File    =strcat(DirWindows(1),"user32.dll")
xx=FileVerInfo(File,"","")
Message("FileVerInfo",xx)
The hard way...
DllName =strcat(DirWindows(1),"Version.dll")
File    =strcat(DirWindows(1),"user32.dll")

; GetFileVersionInfoSizeA  -- Get the size of the buffer for GetFileVersionInfoA
bb=binaryalloc(20)
Buffsize  = DllCall(DllName, long:"GetFileVersionInfoSizeA", lpstr:File,lpbinary:bb)
BinaryFree(bb)

;pause("Buffsize",buffsize")

; GetFileVersionInfoA  -- Get all the version information on the file
verinfobuff=binaryalloc(Buffsize)
BinaryEODSet(verinfobuff, Buffsize)

FileInfo = DllCall(DllName, long:"GetFileVersionInfoA",lpstr:File, long:0, long:buffsize,
lpbinary:verinfobuff )
BinaryWrite(verinfobuff,"c:\incoming\aaa.dat")


; VerQueryValueA   -- Find the Form information and hope its the language returned
Form    ="\VarFileInfo\Translation"
dummybuff=BinaryAlloc(4)
pointerbuf=BinaryAlloc(4)
BinaryEODSet(pointerbuf,4)
LangInfo = DllCall(DllName, long:"VerQueryValueA",lpbinary:verinfobuff, lpstr:Form, lpbinary:pointerbuf,
lpbinary:dummybuff)
;BinaryEODSet(MakeBuff4, LangInfo)



addr=BinaryPeek4(pointerbuf,0)
char2=IntControl(32,addr,"BYTE",0,0)
char1=IntControl(32,addr+1,"BYTE",0,0)
char4=IntControl(32,addr+2,"BYTE",0,0)
char3=IntControl(32,addr+3,"BYTE",0,0)

BinaryFree(pointerbuf)
BinaryFree(dummybuff)
BinaryFree(verinfobuff)


if char1<0 then char1=char1+256
if char2<0 then char2=char2+256
if char3<0 then char3=char3+256
if char4<0 then char4=char4+256

num=(char1 << 24) | (char2 << 16) | (char3 << 8 ) | char4

AddExtender("wilx34I.dll")
hexnum=xBaseConvert(num,10,16)
hexnum=strfixleft(hexnum,0,8)
Message("The hard way",hexnum)

exit

Article ID:   W14466
Filename:   OS Language.txt
File Created: 2001:03:01:14:34:52
Last Updated: 2001:03:01:14:34:52