Please help me get the list of Arguments/Parameters to GetDefaultLayout
function from C:\Windows\System32\input.dll.
This function is about keyboard layouts. And I already know how to get default keyboard layout. I just want to know the parameters for GetDefaultLayout function in input.dll.
For use in Excel VBA but info in any language is appreciated.
Searched all over the internet, no information found.
Another similar undocumented function: GetLayoutDescription
in the same dll was mentioned cyberforum & vbforums (both from 2020) and miloush (from 2010).
Checked exported functions from input.dll using Dll Export Viewer, PE Explorer etc. and found that function listed but no documentation on MS site, unlike other functions, in the same DLL, such as: EnumEnabledLayoutOrTip
.
EnumEnabledLayoutOrTip
and GetLayoutDescription
were successfully called by using a combination of LoadLibrary
, GetProcAddress
& DispCallFunc
using CC_STDCALL and CC_CDECL calling conventions respectively, with Jaafar Triback's help. The arguments were mentioned in the link above. If that could be done, this function should be call-able!
I know that there are other functions like GetKeyboardLayout
or GetKeyboardLayoutName
or GetKeyboardLayoutList
win32 API functions and also know that the same information can be obtained from the Registry, in fact, I know that all these functions retrieve information from the registry. I already knew how to get the keyboard layout information.
The goal of this question is not to get the Default keyboard layout information but to be able to call a function whose arguments/parameters were left unexplained by MS.
I understand that it's been like this for a reason but I am not trying to reverse-engineer it or doing this for profit but to educate myself how to do this and to help others like me.
Disassembling the code can yield the function arguments/parameters but at my current knowledge level, that's too hard.
I was told that arguments/parameters of a function can be viewed in Visual Studio and Ollydbg or IDA etc. but both GetLayoutDescription
and GetDefaultLayout
do not show such information even with undecorate option.
I tried to call it like GetDefaultLayout(StrPtr(sBuffer),uBufLength)
or tried both ANSI or Unicode string passing etc. and even tried passing just a 0&
but still it crashes my Excel file so many times damaging my .xlsm file so much so that I can't even copy/paste into it and currently doing a chkdsk operation.
Thanks in advance.
It is WINAPI HRESULT GetDefaultLayout(LPCWSTR pszUserReg, LPWSTR pszLayout, LPUINT uBufLength);
Usage seems straightforward:
std::wstring GetDefaultLayoutProfileId()
{
typedef HRESULT(WINAPI* GetDefaultLayoutFunc)(LPCWSTR pszUserReg, LPWSTR pszLayout, LPUINT uBufLength);
static GetDefaultLayoutFunc GetDefaultLayout = reinterpret_cast<GetDefaultLayoutFunc>(::GetProcAddress(::LoadLibraryA("input.dll"), "GetDefaultLayout"));
if (!GetDefaultLayout)
return {};
UINT length = 0;
CHECK(SUCCEEDED(GetDefaultLayout(nullptr, nullptr, &length)));
std::wstring defaultLayoutProfileId;
defaultLayoutProfileId.resize(length);
CHECK(SUCCEEDED(GetDefaultLayout(nullptr, defaultLayoutProfileId.data(), &length)));
return defaultLayoutProfileId;
}
...
// Returns default layout profile set in user settings (with IME support!)
// For example "0409:00000409" for English - US layout
std::wstring defaultLayoutProfileId = GetDefaultLayoutProfileId();
string format of the layout is:
<LangID>:<KLID>
The string format of the text service profile (TSF IME) is:
<LangID>:{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
More info here.