<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Install_Win" script:language="StarBasic">&apos;************************************************
&apos;Copyright (C) 2006-2017 Didier Dorange-Pattoret
&apos;38, chemin de l&apos;Abbaye 
&apos;74940 Annecy le Vieux
&apos;France
&apos;ddorange@dmaths.org
&apos;
&apos;
&apos;This library is free software; you can redistribute it and/or
&apos;modify it under the terms of the GNU General Public Licence (GPL)
&apos;as published by the Free Software Foundation; either
&apos;version 2.1 of the License, or (at your option) any later version.

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

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

Public Declare Function GetVersionExA Lib &quot;kernel32&quot; (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&apos;installation se fait avec l&apos;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&apos;installation de Dmaths
Sub TermineInstallationParExe 
	Dim bANettoyer As Boolean 
	bInstallationParExeWin = True
	
&apos;	Print iNumVersionDmathsCourante
	
	Globalscope.BasicLibraries.LoadLibrary(&quot;Standard&quot;)
	MyLibStandard = Globalscope.BasicLibraries.getByName(&quot;Standard&quot;)
	If MyLibStandard.hasByName(&quot;DmOptions&quot;)  Then
		If iNumVersionDmathsCourante &lt; 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(&quot;APPDATA&quot;) &amp; &quot;\Libreoffice\4\user\Dmaths\dmoptions.txt&quot;) Then		
		Globalscope.BasicLibraries.LoadLibrary(&quot;Dmaths&quot;)
		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(&quot;ProgressBar1&quot;).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&apos;affichages
Rem lancée si version précédente de Dmaths &lt; 3.5.7.0  
Sub NettoyageRegistryFile
	Dim TheChemin as String
		TheChemin = getRepertoirePath(&quot;user&quot;) &amp; GetPathSeparator
		 
		aFile = TheChemin &amp; &quot;registrymodifications.xcu&quot;
		aFileNew = TheChemin &amp; &quot;registrymodifications2.xcu&quot;
		
		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, &quot;ImageIdentifier&quot;) = 0 Or InStr(sLine, &quot;soft&quot;) &gt; 0 ) then
				Print #iNumberNew, sLine			
			end if						
		Wend
		Close #iNumber
		Close #iNumberNew
		sNomFichierBatch = fCheminDmaths &amp; &quot;Windows/NettoieRegistreLO.exe&quot;
		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 = &quot;Windows 95&quot;
				Case 10
					sVersion = &quot;Windows 98&quot;
				Case 90
					sVersion = &quot;Windows Millennium&quot;
			End Select
		Case 2
			Select Case .dwMajorVersion
				Case 3
					sVersion = &quot;Windows NT 3.51&quot;
				Case 4
					sVersion = &quot;Windows NT 4.0&quot;
				Case 5
					If .dwMinorVersion = 0 Then
						sVersion = &quot;Windows 2000&quot;
					Else
						sVersion = &quot;Windows XP&quot;
					End If
				Case 6
					If .dwMinorVersion = 0 Then
						sVersion = &quot;Windows Vista&quot;
					Elseif .dwMinorVersion = 1 Then
						sVersion = &quot;Windows 7&quot;
					Elseif .dwMinorVersion = 2 Then
						sVersion = &quot;Windows 8 or Windows 10&quot;
					Else
						sVersion = &quot;Windows 8.1&quot;
					End If
				Case 10
					sVersion = &quot;Windows 10&quot;
				End Select
		Case Else
			sVersion = &quot;Failed&quot;
		End Select
	End With
	getWindowsVersion = sVersion
	Exit Function
	ErreurWindowsVersion:
	sVersion = &quot;Version de Windows non trouvée, OS : &quot; &amp; GetGuiType	
End Function



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



</script:module>