Imports System.Runtime.InteropServices
Imports System.Globalization
Imports System.Threading
Imports Microsoft.Win32
Module Module1
    



    Public strFontName As String
    Public strFontSize As String


    Public blnSynchronousMode As Boolean = False

    
    Public string1 As String
    Public string2 As String
    Public string3 As String
    Public string4 As String
    Public string5 As String
    Public string6 As String
    Public string7 As String
    Public string8 As String
    Public string9 As String
    Public string10 As String
    Public string11 As String
    Public string12 As String
    Public string13 As String
    Public string14 As String
    Public string15 As String
    Public string16 As String
    Public string17 As String
    Public string18 As String
    Public string19 As String
    Public string20 As String
    Public string21 As String
    Public string22 As String
    Public string23 As String
    Public string24 As String
    Public string25 As String
    Public string26 As String
    Public string27 As String
    Public string28 As String
    Public string29 As String
    Public string30 As String
    Public string31 As String
    Public string32 As String
    Public string33 As String
    Public string34 As String
    Public string35 As String


    Public strSEBuildNumber As String
    Public strSEInstalledPath As String
    Public strSEMajorVersion As String
    Public strSEMinorVersion As String
    Public strSESPVersion As String
    Public strSEVersion As String
    Public strLangId As String


    Public Function GetLanguageFolder() As String
        Dim objApp As SolidEdge.Framework.Interop.Application
        Dim DefLangID As Int32 = 1033
        Dim subKey As String
        Dim subKeyPath As String
        Dim seCulture As CultureInfo
        Dim ParentInfo As CultureInfo

        Try
            objApp = GetObject(, "SolidEdge.Application")
            objApp.GetGlobalParameter(SolidEdge.Constant.Interop.ApplicationGlobalConstants.seApplicationGlobalDefaultUserLangID, DefLangID)
            If (DefLangID <> 0) Then
                ' added wait sometimes it shows remote proc call error
                System.Threading.Thread.Sleep(10)
                Dim rkLocalUser As RegistryKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64)
                subKeyPath = objApp.RegistryPath
                subKeyPath += "\CurrentVersion"
                subKey = subKeyPath & "\InstalledLanguage"

                Dim foundKey As RegistryKey = rkLocalUser.OpenSubKey(subKeyPath, RegistryKeyPermissionCheck.ReadSubTree)
                If foundKey IsNot Nothing Then
                    DefLangID = rkLocalUser.GetValue(subKey, 1033)
                    seCulture = New CultureInfo(DefLangID)
                    Thread.CurrentThread.CurrentCulture = seCulture

                    ParentInfo = seCulture.Parent
                    DefLangID = ParentInfo.LCID

                    strLangId = DefLangID.ToString("x4") ' make it 0009
                    GetLanguageFolder = strLangId
                End If
            End If
        Catch ex As Exception
            MsgBox(string2 + " " + string1 + ":" + Err.Description.ToString)
        End Try
    End Function


    Public Function GetSEPath() As String
        Dim objSEInfo As SEInstallDataLib.SEInstallData
        

        objSEInfo = CreateObject("SolidEdge.InstallData")

        'Get Solid Edge information
        strSEBuildNumber = objSEInfo.GetBuildNumber
        strSEInstalledPath = objSEInfo.GetInstalledPath
        strSEMajorVersion = objSEInfo.GetMajorVersion
        strSEMinorVersion = objSEInfo.GetMinorVersion
        strSESPVersion = objSEInfo.GetServicePackVersion
        strSEVersion = objSEInfo.GetVersion
        GetSEPath = strSEInstalledPath

        Garbage_Collect(objSEInfo)

    End Function

    Sub Garbage_Collect(ByVal obj As Object)

        '******* Added because of .NET
        If Not (obj Is Nothing) Then
            Marshal.ReleaseComObject(obj)
        End If

        GC.Collect(GC.MaxGeneration)
        GC.WaitForPendingFinalizers()
        GC.Collect(GC.MaxGeneration)
        GC.WaitForPendingFinalizers()
        '******* Added because of .NET
    End Sub
End Module
