[API]
Public FreeLibrary

[DEFINE]
Public LoadResEx_LanguageFile_hModule As Long

[INCLUDE]
LoadLibrary
LoadResEx_String

[CODE]
Public Function LoadResEx_SetLanguageFile(Optional ByVal Filename As String, Optional ByVal IdentifyString As String) As Boolean
  Dim xLong1 As Long

  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
    LoadResEx_LanguageFile_hModule = LoadLibrary(Filename)
    If LoadResEx_LanguageFile_hModule = 0& Then
      LoadResEx_LanguageFile_hModule = App.hInstance
      Else
      If Len(IdentifyString) = 0& Then
        LoadResEx_SetLanguageFile = True
        Else
        If IsUnicode Then
          xLong1 = LoadStringW(LoadResEx_LanguageFile_hModule, 1&, ptrTemp, ptrTempSizeXW)
          Else
          xLong1 = LoadStringA(LoadResEx_LanguageFile_hModule, 1&, ptrTemp, ptrTempSizeXW)
          End If
        If Not xLong1 = 0& Then
          If IdentifyString = PeekS(ptrTemp, xLong1) Then
            LoadResEx_SetLanguageFile = True
            GoTo Success
            End If
          End If
        FreeLibrary LoadResEx_LanguageFile_hModule
        LoadResEx_LanguageFile_hModule = App.hInstance
Success:
        End If
      End If
    End If
  End Function