Configuration provider - 32 v 64 bit

Good Morning,
I have been trying to programmatically determine if the version of LO that I have is 32 bit or 64 bit (I know it is 32 bit). I was able to learn a few pieces of detail from Apache OpenOffice Community Forum - [Solved] Retrieving OO version (OO + VB6) - (View topic)
Here is the code:

Sub main1
Print getOOoVersion()
End Sub


Function getOOoVersion() As String

  getOOoVersion = getOOoSetupValue("/org.openoffice.Setup/Product","ooSetupVersion")
end Function
Function getOOoSetupNode(sNodePath$)
Dim aConfigProvider, oNode, args(0) As new com.sun.star.beans.PropertyValue
	aConfigProvider = createUnoService("com.sun.star.configuration.ConfigurationProvider")
	args(0).Name = "nodepath"
	args(0).Value = sNodePath
	getOOoSetupNode = aConfigProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", args())
End Function
Function getOOoSetupValue(sNodePath$,sProperty$)
Dim oNode
	oNode = getOOoSetupNode(sNodePath)
	getOOoSetupValue = oNode.getbyname(sProperty)
End Function

The function getOOoSetupNode has all kinds of attributes related to product information, but nothing associated to whether it is a 32 bit or 64 application. Thank you for your help.

Regards

Zafar

Well I found the answer:

Sub main2
	SF_Platform = createscriptservice("Platform")
	print SF_Platform.ArchiTecture
    SF_Platform.Dispose
End Sub

Here is an another approach, it works for me (except, when you use a custom directory for the installation without any x64/x32 flag in its name.:

Function IsLOx64() as boolean

 Dim oContext as object 
 Dim sUrl as string

	oContext = GetDefaultContext().getByName("/singletons/com.sun.star.util.theOfficeInstallationDirectories")
	sUrl = oContext.OfficeInstallationDirectoryURL

	if (Instr(sUrl,"x86")>0) or (Instr(sUrl,"_32")>0) then
    	IsLOx64 = false
	else
    	IsLOx64 = true
	end if

End Function
1 Like

The question is - why the architecture is required in a Basic macro (ScriptForge uses Python for that; using Python instead of Basic would be enough, and would not incur the “call Python from Basic” performance penalty).

1 Like

Agreed. However, as many of my posts are in Python, I am still on the learning track, and i have a job that doesn’t care about what programming language I use as long as i get my data processing work done. So ScriptForge it is.

Thank you for that. The problem is that my installation of LibreOffice (portable app) does not get installed in the standard directory/

Note that this does not answer why a script might need to know the process architecture. I suppose this would only matter on Windows, where it’s possible to run 32-bit process in 64-bit environment. This would allow to provide more ways (like using kernel32 functions, or other ways - so knowing details helps); also, it’s possible that looking for the architecture is a manifestation of an XY problem, and there could be better ways solving the actual problem than knowing that.