 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
RobOtter
Joined: 30 Jan 2005 Posts: 125 Location: Darmstadt, Germany
|
Posted: Mon Mar 31, 2008 2:59 pm Post subject: DllCall example for "RegLoadMUIStringW" |
|
|
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! ] |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2558 Location: Australia, Qld
|
Posted: Tue Apr 01, 2008 6:24 am Post subject: |
|
|
| 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%
|
|
|
| Back to top |
|
 |
RobOtter
Joined: 30 Jan 2005 Posts: 125 Location: Darmstadt, Germany
|
Posted: Fri Apr 04, 2008 7:17 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|