Manche Makro-Befehle sind sprachabhängig (StartCommand).

Es gibt wenig Routinen um die Catia - Umgebungssprache zu bestimmen.

Die nachfolgende stammt zu grossen Teilen aus einem Thread von 2004. ( http://ww3.cad.de/foren/ubb/Forum137/HTML/000742.shtml#000011 )


Option Explicit

Private Declare Function GetUserDefaultLangID Lib "kernel32" () As Integer
Private Declare Function GetSystemDefaultLangID Lib "kernel32" () As Integer

Sub catmain()
   GetV5Lang
Kill CATIA.SystemService.Environ("CATTEMP") & "\FrameGeneral.xml"
End Sub

Function UserDefLang() As String
   Select Case LoByte(GetUserDefaultLangID)
   
      Case 4
         UserDefLang = "Simplified Chinese"
      Case 7
         UserDefLang = "German"
      Case 9
         UserDefLang = "English"
      Case 10
         UserDefLang = "Spanish"
      Case 12
         UserDefLang = "French"
      Case 16
         UserDefLang = "Italian"
      Case 17
         UserDefLang = "Japanese"
      Case 18
         UserDefLang = "Korean"
      Case Else
         MsgBox "LangID: " & LoByte(GetSystemDefaultLangID)
   End Select

End Function

Function HiByte(ByVal wParam As Long) As Integer
    HiByte = wParam \ &H100 And &HFF&
End Function

Function LoByte(ByVal wParam As Long) As Integer
    LoByte = wParam And &HFF&
End Function

Ab hier der Original-Thread:


Sub GetV5Lang()
   Dim shelltext As String
   Dim Filetxt As String
   Dim txt As String
   Dim iLangCode As Integer
   Dim sLanguage As String

   shelltext = Chr(34) & CATIA.SystemService.Environ("CATDLLPATH") & _
               "\CATBatGenXMLSet.exe" & Chr(34) & " " & Chr(34) & _
               CATIA.SystemService.Environ("CATTEMP") & Chr(34) & " FrameGeneral"

   Shell shelltext, vbHide
   Filetxt = txt_ReadAll(CATIA.SystemService.Environ("CATTEMP") & _
                         "\FrameGeneral.xml")

   txt = LTrim2(Filetxt, InStr(Filetxt, "UserInterfaceLanguage"))
   txt = Left(txt, InStr(txt, "</Attribute>") - 1)
   If InStr(txt, "<Value>") = 0 Then
      'value 4 lang not found
      Exit Sub
   End If

   txt = LTrim2(txt, InStr(txt, "<Value>") + 6)
   iLangCode = CInt(RTrim2(txt, Len(txt) - InStr(txt, "</Value>") + 1))

   Select Case iLangCode
      Case 0
         'sLanguage = "System Default"
         sLanguage = UserDefLang
      Case 714
         sLanguage = "English"
      Case 598
         sLanguage = "French"
      Case 602
         sLanguage = "German"
      Case 706
         sLanguage = "Italian"
      Case 807
         sLanguage = "Japanese"
      Case 608
         sLanguage = "Korean"
      Case 1828
         sLanguage = "Simplified Chinese"
   End Select

   MsgBox sLanguage

End Sub

Private Function txt_ReadAll(ByVal sFilename As String) As String

  Dim F As Integer
  Dim sInhalt As String

  ' Existiert die Datei ?
  If Dir$(sFilename, vbNormal) <> "" Then
    ' Textdatei im Binärmodus öffnen und gesamten
    ' Inhalt in einem Rutsch auslesen
    F = FreeFile
    Open sFilename For Binary As #F
    sInhalt = Space$(LOF(F))
    Get #F, , sInhalt
    Close #F
  End If

  txt_ReadAll = sInhalt
End Function

Private Function LTrim2(ByVal str As String, ByVal dig As Integer)
    LTrim2 = Right(str, Len(str) - dig)
End Function

Private Function RTrim2(ByVal str As String, ByVal dig As Integer)
    RTrim2 = Left(str, Len(str) - dig)
End Function

Zum Seitenanfang