'************************************************ 'Copyright (C) 2006-2017 Didier Dorange-Pattoret '38, chemin de l'Abbaye '74940 Annecy le Vieux 'France 'ddorange@dmaths.org ' ' 'This library is free software; you can redistribute it and/or 'modify it under the terms of the GNU General Public Licence (GPL) 'as published by the Free Software Foundation; either 'version 2.1 of the License, or (at your option) any later version.

'This library is distributed in the hope that it will be useful, 'but WITHOUT ANY WARRANTY; without even the implied warranty of 'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 'General Public License for more details.

'You should have received a copy of the GNU General Public Licence (GPL) 'along with this library; if not, write to the Free Software 'Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA '************************************************

Public Declare Function GetVersionExA Lib "kernel32" (lpVersionInformation As OSVERSIONINFO) As Integer

Type OSVERSIONINFO dwOSVersionInfoSize As Long dwMajorVersion As Long dwMinorVersion As Long dwBuildNumber As Long dwPlatformId As Long szCSDVersion As String * 128 End Type

Rem vaut true si l'installation se fait avec l'exe windows Public bInstallationParExeWin As Boolean

Rem macro ecrite le 3 decembre 2016 pour installer Dmaths pour Word Sub TermineInstallationParExeWord ChargerLODemarrage TermineInstallationParExe End Sub

Rem macro écrite le 1er novembre 2015, modifiée le 10 janvier 2016 Rem Permet de terminer l'installation de Dmaths Sub TermineInstallationParExe Dim bANettoyer As Boolean bInstallationParExeWin = True

' Print iNumVersionDmathsCourante

Globalscope.BasicLibraries.LoadLibrary("Standard") MyLibStandard = Globalscope.BasicLibraries.getByName("Standard") If MyLibStandard.hasByName("DmOptions") Then If iNumVersionDmathsCourante < 3570 Then bANettoyer = True Else bANettoyer = False Call DmInstall.Install_Addon.LanceFinInstallation(TRUE,FALSE) If bANettoyer Then NettoyageRegistryFile Rem nettoie le fichier registrymodifications.xcu

ElseIf FileExists(environ("APPDATA") & "\Libreoffice\4\user\Dmaths\dmoptions.txt") Then Globalscope.BasicLibraries.LoadLibrary("Dmaths") Call Dmaths.DmathsOptions.LoadOptionsDmaths Call DmInstall.Install_Addon.LanceFinInstallation(TRUE,FALSE) rem on effectue une mise à jour Else Call DmInstall.Install_Addon.LanceFinInstallation(FALSE,FALSE) rem le parametre est False on effectue une installation nouvelle EndIf Rem fermeture de la boite contenant la barre de progression oDmProgInst.getControl("ProgressBar1").Value = 100 oDmProgInst.Dispose() StarDesktop.SuspendQuickstartVeto = True StarDesktop.terminate End Sub

Rem macro ecrite le 5 novembre 2015 Rem permet de nettoyer le fichier registrymodifications.xcu pour éviter les erreurs d'affichages Rem lancée si version précédente de Dmaths < 3.5.7.0 Sub NettoyageRegistryFile Dim TheChemin as String TheChemin = getRepertoirePath("user") & GetPathSeparator

aFile = TheChemin & "registrymodifications.xcu" aFileNew = TheChemin & "registrymodifications2.xcu"

iNumberNew = Freefile Open aFileNew For Output As iNumberNew iNumber = Freefile Open aFile For Input As iNumber While not eof(iNumber) Line Input #iNumber, sLine If (InStr(sLine, "ImageIdentifier") = 0 Or InStr(sLine, "soft") > 0 ) then Print #iNumberNew, sLine end if Wend Close #iNumber Close #iNumberNew sNomFichierBatch = fCheminDmaths & "Windows/NettoieRegistreLO.exe" Shell(sNomFichierBatch,10,OOoName,False) End Sub

Rem macro ajoutee le 2 novembre 2016, permet de déterminer le type de Windows (XP, 7, 8, 10 ...) Function getWindowsVersion() As String On error goto ErreurWindowsVersion Dim osinfo As OSVERSIONINFO Dim retvalue As Integer Dim sVersion as String osinfo.dwOSVersionInfoSize = 148 osinfo.szCSDVersion = Space$(128) retvalue = getVersionExA(osinfo)

With osinfo Select Case .dwPlatformId Case 1 Select Case .dwMinorVersion Case 0 sVersion = "Windows 95" Case 10 sVersion = "Windows 98" Case 90 sVersion = "Windows Millennium" End Select Case 2 Select Case .dwMajorVersion Case 3 sVersion = "Windows NT 3.51" Case 4 sVersion = "Windows NT 4.0" Case 5 If .dwMinorVersion = 0 Then sVersion = "Windows 2000" Else sVersion = "Windows XP" End If Case 6 If .dwMinorVersion = 0 Then sVersion = "Windows Vista" Elseif .dwMinorVersion = 1 Then sVersion = "Windows 7" Elseif .dwMinorVersion = 2 Then sVersion = "Windows 8 or Windows 10" Else sVersion = "Windows 8.1" End If Case 10 sVersion = "Windows 10" End Select Case Else sVersion = "Failed" End Select End With getWindowsVersion = sVersion Exit Function ErreurWindowsVersion: sVersion = "Version de Windows non trouvée, OS : " & GetGuiType End Function

Function IsWin8or10 As Boolean If getguitype = 1 And (Instr(getWindowsVersion,"Windows 10")>0 or Instr(getWindowsVersion,"Windows 8")>0) Then IsWin8or10 = True Else IsWin8or10 = False Endif End Function