如何取得系統語系及國別

VB相關技術
回覆文章
頭像
tim
文章: 1380
註冊時間: 2008年 11月 26日, 00:49

如何取得系統語系及國別

文章 tim »

可以利用API GetLocaleInfo 來取得相關資訊, 範例程式如下:

語法:

代碼: 選擇全部

     
    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 
     
    Private Sub form_Load() 
        MsgBox GetInfo(&H1002) 
        MsgBox GetInfo(&H8) 
        MsgBox GetInfo(&H1001) 
        MsgBox GetInfo(&H4) 
    End Sub 
     
    Public Function GetInfo(ByVal lInfo As Long) As String 
        Dim Buffer As String, Ret As String 
        Buffer = String$(256, 0) 
        Ret = GetLocaleInfo(LOCALE_USER_DEFAULT, lInfo, Buffer, Len(Buffer)) 
        If Ret > 0 Then 
            GetInfo = Left$(Buffer, Ret - 1) 
        Else 
            GetInfo = "" 
        End If 
    End Function 





API用法:
http://msdn.microsoft.com/library/defau ... s_34rz.asp
LCTYPE常數:
http://msdn.microsoft.com/library/defau ... s_8rse.asp
藍色小舖討論:
http://www.blueshop.com.tw/board/show.a ... 5F&fumcde=
多多留言, 整理文章, 把經驗累積下來.....
回覆文章