Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28500 Discussions

How to supply correct parameters for SetThreadPreferredUILanguages function

alb_f
Novice
227 Views

I want use the function SetThreadPreferredUILanguages() in a Fortran routine. It needs two/three parameters as follows:

 

[in]            DWORD    dwFlags,
[in, optional]  PCZZWSTR pwszLanguagesBuffer,
[out, optional] PULONG   pulNumLanguages

 

The first parameter can simply be set to MUI_LANGUAGE_NAME. However, I have trouble finding out the correct Fortran types for the second and third parameter.

When used as

 

Use ISO_C_BINDING
Integer(Bool) :: bRet

bRet = SetThreadPreferredUILanguages(MUI_LANGUAGE_NAME, NULL, NULL)

 

it returns a TRUE so the function does work in principle.

When I use it as

 

Use ISO_C_BINDING
Integer(Bool) :: bRet
Character(15), Pointer :: p_string
Character(15), Target :: string

string = "fr-FR"//Char(0)//"nl-NL"//Char(0)//Char(0)
p_string => string
bRet = SetThreadPreferredUILanguages(MUI_LANGUAGE_NAME, p_string, NULL)

 

it returns a FALSE indicating that it is called incorrectly I assume. But what is the right way of providing the parameters?

Forgot to mention: I use an interface like

interface
  logical(4) function SetProcessPreferredUILanguages(mode, lan, nlan)
  !DEC$ATTRIBUTES STDCALL, ALIAS: '_SetProcessPreferredUILanguages@4':: SetProcessPreferredUILanguages
  !DEC$ATTRIBUTES REFERENCE :: nlan, lan
  integer(4) :: mode
  character(*) :: lan
  integer :: nlan
  end function
end interface 
0 Kudos
0 Replies
Reply