----- Original Message ----- 
From: "Dennis McGrath" <[EMAIL PROTECTED]>
To: "RBASE-L Mailing List" <[email protected]>
Sent: Thursday, March 06, 2008 3:22 PM
Subject: [RBASE-L] - RE: How To: Get the Users Country
>

Mike, that is cool, but I have a warning.
All those hard coded 48's are a crash waiting to happen as they define the size 
of the buffer.  Use a variable instead defined one place and use it instead of 
the hard coded numbers.
Set var vBufferSize INT = 48
>

In the STDCALL declaration, when TEXT (n) is specified, the engine adds the 
terminating NULL.

The Size 48 was just for the example and is not requesite.  You could of 
course, use a variable in its place IF your country name is longer than 48 
characters.   In this instance, using 48, if the country name was longer than 
48, it would just be truncated.




ALso fill lplcdata with one extra zero.
SET VAR lplcdata TEXT = (SFIL((CHAR(0)),(.vBuffersize + 1)))
It assures that your string in memory will always be properly zero terminated, 
just to be safe.

Dennis McGrath

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of MikeB
Sent: Thursday, March 06, 2008 2:06 PM
To: RBASE-L Mailing List
Subject: [RBASE-L] - How To: Get the Users Country

Did you know you can get the Users Country by calling the GetLocaleInfo API
using the NEW DLCall function?

Here's how:

{
   only call STDCALL for this function ONCE per session
   Fill the lplcdata variable with nulls the length of our pointer PTR to it
passed to the function
   The function will populate the pointer variable with the country name

}
STDCALL function 'GetLocaleInfoA' ALIAS 'GetLocaleInfo' (integer, ptr text
(48), integer, integer) : integer


SET VAR lplcdata TEXT = (SFIL((CHAR(0)),48))

SET VAR USER_DEFAULT INTEGER = 1024
SET VAR sengcountry  INTEGER = 4098 -- English name of country
SET VAR SENGLANGUAGE  INTEGER = 4097  -- English name of language
SET VAR SNATIVELANGNAME INTEGER = 4  -- native name of language
SET VAR SNATIVECTRYNAME INTEGER = 8

SET VAR i INTEGER = 0

SET VAR i = (dlcall('Kernel32','GetLocaleInfo', 48, lplcdata, SNATIVECTRYNAME,
USER_DEFAULT))

PAUSE 2 USING .lplcdata
RETURN


Reply via email to