Attribute VB_Name = "Module6"
Option Explicit
Option Base 0

#If InIDE Then
  Private Declare Function LoadLibraryA Lib "kernel32" (ByVal lpLibFileName As String) As Long
  Private Declare Function LoadLibraryW Lib "kernel32" (ByVal lpLibFileName As Long) As Long
  Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long

  Public LoadResEx_LanguageFile_hModule As Long

  Public Function LoadResEx_SetLanguageFile(Optional ByVal Filename As String, Optional ByVal IdentifyString As String) As Boolean
    If Not LoadResEx_LanguageFile_hModule = App.hInstance Then
      Call FreeLibrary(LoadResEx_LanguageFile_hModule)
      LoadResEx_LanguageFile_hModule = App.hInstance
      End If
    If Not Len(Filename) = 0& Then
      #If Unicode Then
        If IsUnicode Then
          LoadResEx_LanguageFile_hModule = LoadLibraryW(StrPtr(Filename))
          Else
          LoadResEx_LanguageFile_hModule = LoadLibraryA(Filename)
          End If
        #Else
        LoadResEx_LanguageFile_hModule = LoadLibraryA(Filename)
        #End If
      
      If LoadResEx_LanguageFile_hModule = 0& Then
        LoadResEx_LanguageFile_hModule = App.hInstance
        Else
        If Len(IdentifyString) = 0& Then
          LoadResEx_SetLanguageFile = True
#If LoadResEx_String Then
          ElseIf LoadResEx_String(1&) = IdentifyString Then
#End If
          LoadResEx_SetLanguageFile = True
          Else
          FreeLibrary LoadResEx_LanguageFile_hModule
          LoadResEx_LanguageFile_hModule = App.hInstance
          End If
        LoadResEx_SetLanguageFile = True
        End If
      End If
    End Function
  #End If

