You don't know.-restrict the software to run in the specified local settings.

Source: Internet
Author: User
Today, when processing a program, we found some exceptions, that is, if the settings in the control panel use simplified Chinese, the program runs normally, however, if the system is set up in English or other countries, an error is reported.

Generally, this error occurs because the program has a tight relationship with the local settings in the control panel, such as the date format and local financial symbols, however, my program uses the rc6 algorithm to encrypt some strings. If the encryption and decryption ends are different from the local settings, the obtained content is inconsistent.

Haha, my solution is to restrict users to use it in simplified Chinese environments, but they are all used by Chinese people. In this way, I am lazy and use the following code.

'Read the local language code
Private const locale_user_default = & H400
Private const locale_ilanguage = & H1
Private declare function getlocaleinfo lib "Kernel32" alias "getlocaleinfoa" (byval locale as long, byval lctype as long, byval lplcdata as string, byval cchdata as long) as long

'Obtain the local language code
Private function getlocallanguagecode () as string
Dim buffer as string * 100
Dim DL as long

# If Win32 then
DL = getlocaleinfo (locale_user_default, locale_ilanguage, buffer, 99)
Getlocallanguagecode = lpstrtovbstring (buffer)
# End if

End Function

'Conversion string
Private function lpstrtovbstring (byval s as string) as string
Dim nullpos as long
Nullpos = instr (S, CHR (0 ))
If nullpos> 0 then
Lpstrtovbstring = left $ (S $, nullpos-1)
Else
Lpstrtovbstring = ""
End if
End Function

'Application:
If getlocallanguagecode <> "0804" then
Msgbox "Local Control Panel setting error, must be set to Chinese Simplified.", vbcritical, "prompt"
End
End if

In this way, the user is limited to perform operations in the specified local settings. This is not a good method, but it is enough.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.