[Solved] Detect Operating System
Posted: Fri Jan 08, 2010 1:18 am
Is there a way to detect, on which Operating System OOo Basic runs?
User community support forum for Apache OpenOffice, LibreOffice and all the OpenOffice.org derivatives
https://forum.openoffice.org/en/forum/
Code: Select all
GetGuiType Function [Runtime]
Returns a numerical value that specifies the graphical user interface.
This runtime function is only provided for downward compatibility to previous versions. The return value is not defined in client-server environments.
Syntax:
GetGUIType()
Return value:
Integer
Return values:
1: Windows
3: Mac OS
4: UNIX
Code: Select all
'==========================================
'determine Operating System
'==========================================
function OS()as string
select case getGUIType
case 1: OS="WINDOWS"
case 3: OS="MAC"
case 4: OS=iif(instr(environ("PATH"),"openoffice")=0,"OSX","UNIX")
end select
end function
Code: Select all
Function SpeechEngine()as string
select case getGUIType
case 1: SpeechEngine=iif(fileExists (fsProgramDirectory & "eSpeak\command_line\espeak.exe"),"ESPEAK","SAPI") 'Win
case 3: SpeechEngine=iif((fileExists("/usr/bin/espeak") or ifileExists("/usr/local/bin/espeak")),"ESPEAK","SAY") 'Old Mac
case else: SpeechEngine=iif((fileExists("/usr/bin/espeak") or fileExists("/usr/local/bin/espeak")),"ESPEAK","SAY") 'Posix
end select
end Function
Function fsProgramDirectory
Dim c as string
c = environ("ProgramFiles")
if instr(c, "\") <> 0 then
fsProgramDirectory= c & "\"
else
fsProgramDirectory="/usr/bin/"
end if
End Function
Code: Select all
Function getOS()as String
Select Case getGUIType
Case 1:
getOS="WINDOWS"
Case 3:
getOS="MAC"
Case 4:
If Instr(Environ("PATH"),"openoffice")=0 And Instr(Environ("PATH"),Lcase(fsGetSetting("ooname")))=0 Then
getOS="OSX"
Else
getOS="UNIX"
Endif
End Select
End Function
Function fsGetSetting(sA)
GlobalScope.BasicLibraries.LoadLibrary("Tools")
Dim oProdNameAccess As Object
oProdNameAccess=GetRegistryKeyContent("org.openoffice.Setup/Product")
Select Case Lcase(sA)
Case "language"
fsGetSetting=GetStarOfficeLocale().language
Case "country"
fsGetSetting=GetStarOfficeLocale().country
Case "ooname"
fsGetSetting=oProdNameAccess.getByName("ooName")
Case "ooversion"
fsGetSetting=oProdNameAccess.getByName("ooSetupVersion")
Case Else
fsGetSetting="???"
End Select
End Function