Archive: Confusion on GetKeyboardLayoutList Function


Confusion on GetKeyboardLayoutList Function
I am confused with the usage of this code in red:

System::Call 'user32::GetKeyboardLayoutList(i ${NSIS_MAX_STRLEN},i R0)i.r4'
should it not be with a dot: i .R0 ?

in MSDN it says:

UINT GetKeyboardLayoutList(int nBuff, HKL *lpList);

nBuff
[in] Specifies the maximum number of handles that the buffer can hold.
lpList
[out] Pointer to the buffer that receives the array of input locale identifiers.
does OUT not mean DESTINATION?

Yes, OUT means destination. It depends however on the type of output.

In your example the output is a memory buffer and if it has been pre-alocated then there is no reason to use a dot.

Also, it is a pointer which implies the use of a *
However, if it is a pre-allocated buffer, then the variable that points to it is already a pointer, so no need for the *

Check the entire call:

System::Alloc ${NSIS_MAX_STRLEN}
Pop $R0
System::Call 'user32::GetKeyboardLayoutList(i ${NSIS_MAX_STRLEN}, i R0)i.r0'
The first part allocates a portion of memory equal to ${NSIS_MAX_STRLEN} and then the buffer location is popped into $R0. So when the second call occurs, $R0 is already a pointer to a buffer, so it is referenced as iR0 rather than *iR0 or *i.R0.

Hope this helps,
CF