AutoHotkey Community

It is currently May 26th, 2012, 5:16 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: March 31st, 2008, 2:59 pm 
Offline

Joined: January 30th, 2005, 11:18 pm
Posts: 133
Location: Darmstadt, Germany
Under Vista, I´d like to read the registry values of availabe keyboard layouts (HKLM\SYSTEM\CurrentControlSet\Control\Keyboard Layouts\* ).
The strings specific for the user language of the Vista installation are located in the key "Layout Display Name". Unfortunately, one will find just a kind of "link" there, pointing into a DLL (i.e. "@C:\Windows\system32\input.dll,-5011").
Now, how can I read the strings behind this link? Afte digging in the dirt of MSDN, I´ve found the DLL function RegLoadMUIStringW() which might do the job - only problem is: how do I call it correctly with DllCall? I cannot figure out which variable types I should use etc.

TIA,
Rob

[ Moderator!: MSDN link fixed! ]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 1st, 2008, 6:24 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7501
Location: Australia
Code:
HKCR = 0x80000000
HKCU = 0x80000001
HKLM = 0x80000002
HKU  = 0x80000003

RegKeyRoot := HKLM
RegKey = SYSTEM\CurrentControlSet\Control\Keyboard Layouts\00000409
RegValue = Layout Display Name

KEY_QUERY_VALUE = 0x0001

; Get a handle to the registry key containing the value.
DllCall("Advapi32\RegOpenKeyExA","uint",RegKeyRoot,"str",RegKey
                    ,"uint",0,"uint",KEY_QUERY_VALUE,"uint*",hKey)

; Convert RegValue to a Unicode string.
cch := VarSetCapacity(wRegValue,StrLen(RegValue)*2+2)//2
DllCall("MultiByteToWideChar","uint",0,"uint",0
            ,"str",RegValue,"int",-1
            ,"uint",&wRegValue,"int",cch)

; Determine buffer size required to retrieve the string.
DllCall("Advapi32\RegLoadMUIStringW"
    ,"uint",hKey        ; handle to registry key
    ,"uint",&wRegValue  ; name of registry value
    ,"uint",0
    ,"uint",0
    ,"uint*",StringSize ; out: required buffer size
    ,"uint",0
    ,"uint",0)

VarSetCapacity(wStr, StringSize)
; Retrieve the string.
DllCall("Advapi32\RegLoadMUIStringW"
    ,"uint",hKey
    ,"uint",&wRegValue
    ,"uint",&wStr       ; output buffer
    ,"uint",StringSize  ; size of output buffer
    ,"uint*",StringSize ; out: number of bytes copied
    ,"uint",0
    ,"uint",0)

; Convert the result from Unicode to ANSI.
VarSetCapacity(Str, StringSize//2)
DllCall("WideCharToMultiByte","uint",0,"uint",0
            ,"uint",&wStr,"int",StringSize//2
            ,"str",Str,"int",StringSize//2
            ,"uint",0,"uint",0)

MsgBox %Str%


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 4th, 2008, 7:17 am 
Offline

Joined: January 30th, 2005, 11:18 pm
Posts: 133
Location: Darmstadt, Germany
Many thanks, works like a charm!

I´m sure that with this information, I can derive a similar solution for XP by myself - the RegLoadMUIStringW function is not provided prior to Vista, but afaik similar functions are avail.

Thanks again,
Rob


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Alpha Bravo, Google [Bot], mrhobbeys, oldbrother, poserpro, rbrtryn and 69 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group