|
-
Nov 6th, 2001, 05:07 AM
#1
Thread Starter
Fanatic Member
changing the windows codepage
how can i detect what codepage windows is using and change it
For e.g if windows is using English codepage i want to change it to Greek code page and the opposite
thnks
-
Nov 6th, 2001, 06:01 AM
#2
The ANSI code page used internally by Windows - GetACP() api
The current OEM code page GetOEMCP() api
LoadKeyboardLayout() changes the OEM code page
EnumSystemCodePages() gives all of the available OEM & ansi
code pages.
WARNING>>>
if you change OEM code pages, you can trash the file system.
The FAT32 file name information is written to disk using the current codepage. If you change code pages and then write more files to disk, you may not be able to get them from disk later, using another code page. In other words - don't flip-flop between code pages.
-
Nov 6th, 2001, 07:16 AM
#3
Thread Starter
Fanatic Member
the only thing i want to do is change the keybord layout should i follow that way or is it a better one
-
Nov 6th, 2001, 09:41 AM
#4
Use LoadKeyBoardLayout
Sample code:
Code:
'This example was created by A.E.Veltstra
'This fucntion changes the locale and as a result, the keyboardlayout gets adjusted
'parameters for api's
Const KL_NAMELENGTH As Long = 9 'length of the keyboardbuffer
Const KLF_ACTIVATE As Long = &H1 'activate the layout
'the language constants
Const LANG_NL_STD As String = "00000413"
Const LANG_EN_US As String = "00000409"
Const LANG_DU_STD As String = "00000407"
Const LANG_FR_STD As String = "0000040C"
'api's to adjust the keyboardlayout
Private Declare Function GetKeyboardLayoutName Lib "user32" Alias "GetKeyboardLayoutNameA" (ByVal pwszKLID As String) As Long
Private Declare Function LoadKeyboardLayout Lib "user32" Alias "LoadKeyboardLayoutA" (ByVal pwszKLID As String, ByVal flags As Long) As Long
Public Function SetKbLayout(strLocaleId As String) As Boolean
'Changes the KeyboardLayout
'Returns TRUE when the KeyboardLayout was adjusted properly, FALSE otherwise
'If the KeyboardLayout isn't installed, this function will install it for you
On Error Resume Next
Dim strLocId As String 'used to retrieve current KeyboardLayout
Dim strMsg As String 'used as buffer
Dim lngErrNr As Long 'receives the API-error number
'create a buffer
strLocId = String(KL_NAMELENGTH, 0)
'retrieve the current KeyboardLayout
GetKeyboardLayoutName strLocId
'Check whether the current KeyboardLayout and the
'new one are the same
If strLocId = (strLocaleId & Chr(0)) Then
'If they're the same, we return immediately
SetKbLayout = True
Else
'create buffer
strLocId = String(KL_NAMELENGTH, 0)
'load and activate the layout for the current thread
strLocId = LoadKeyboardLayout((strLocaleId & Chr(0)), KLF_ACTIVATE)
If IsNull(strLocId) Then 'returns NULL when it fails
SetKbLayout = False
Else 'check again
'create buffer
strLocId = String(KL_NAMELENGTH, 0)
'retrieve the current layout
GetKeyboardLayoutName strLocId
If strLocId = (strLocaleId & Chr(0)) Then
SetKbLayout = True
Else
SetKbLayout = False
End If
End If
End If
End Function
Private Sub Form_Load()
'change the current keybour layout to 'English - US'
SetKbLayout LANG_EN_US
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|