1. Tracy Lamb
  2. PowerBuilder
  3. Tuesday, 9 August 2022 23:58 PM UTC

Me again!

I have 32-bit and 64-bit versions of my app.  The app includes the ability to email documents.  But, if the customer is running the 32-bit version, and the Outlook version they have installed is 64-bit, they  get an error.  And visa-versa.

Is there a way to check the "bitness" of their installed Outlook before the code runs the Send Email command?  I know which version of my software they are running.  But the 32-bit version works on both 32 and 64 bit machines.  I need to know the "bitness" of their installed Outlook .. and pop-up a message if they don't match.  

~~~Tracy

 

Accepted Answer
Tracy Lamb Accepted Answer Pending Moderation
  1. Thursday, 11 August 2022 00:42 AM UTC
  2. PowerBuilder
  3. # Permalink

Thank you Mark, John and Roland!

This was definitely a research project!  All the different versions and configurations of Outlook was getting tough to decipher.  In the end, I decided on Mark's solution 2...

Here's the code now... it's in the pfc_postopen event. ue_no_email disables the email options on the window and notifies the user.

//Check to see if the Outlook "bitness" matches the BT "bitness"
string ls_directory, ls_path
integer li_rc, li_BtBitness, li_Outlook
ulong ll_OutlookBitness
boolean lb_rc
environment lenv_object

li_rc = RegistryGet ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE", &
   "Path", RegString!, ls_directory)
if (li_rc = -1) then
	this.Post Event ue_no_email()
	return
else
	lb_rc = GetBinaryTypeW( ls_directory + "\OUTLOOK.EXE", ll_OutlookBitness)
	if lb_rc = FALSE then
		this.Post Event ue_no_email()
		return
	elseif ll_OutlookBitness = 0 then
		ll_OutlookBitness = 32
	elseif ll_OutlookBitness = 6 then
		ll_OutlookBitness = 64
	end if
	
	GetEnvironment (lenv_object)
	li_BtBitness = 	lenv_object.processbitness

	if li_BtBitness <> ll_OutlookBitness then
		this.Post Event ue_no_email()
		return
	end if
end if


In the application object I declared the global external function: FUNCTION boolean GetBinaryTypeW( string lpApplicationName, ref ulong lpBinaryType) LIBRARY "kernel32.dll".  I don't know what versions of Windows all my customers are using, Probably Win7 - Win11, but some old farts might still be running XP !!! lol!

Again, I'm very grateful 

~~~Tracy

 

 

 

Comment
  1. John Fauss
  2. Thursday, 11 August 2022 02:52 AM UTC
That's great news, Tracy!

The minimum desktop version of Windows that supports the GetBinaryTypeW API function is Windows XP. For servers it is Windows Server 2003.
  1. Helpful
  1. Mark Goldsmith
  2. Thursday, 11 August 2022 12:10 PM UTC
Thanks for the update Tracy and glad to hear that worked for you (and thanks for sharing your solution)!
  1. Helpful
There are no comments made yet.
Mark Goldsmith Accepted Answer Pending Moderation
  1. Wednesday, 10 August 2022 16:31 PM UTC
  2. PowerBuilder
  3. # 1

Hi Tracy,

In addition to the other great suggestions you could:

1) Use the GetBinaryTypeA/W() API call on the app path value (see number 2).

2) Similar to John's suggestion look at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE, this key avoids having to worry about which version (14, 16 etc.) of Outlook may be installed.

3) Using OLE, connect to Outlook and pull the Application.ProductCode value, which is the app's GUID, the 20th position is either a 0 (32 bit) or 1 (64 bit); as this is not involving the use of mailsession/ MAPI, it shouldn't matter whether your application is 32 bit or 64 bit when just checking this value.

HTH...regards,

Mark

Comment
  1. Roland Smith
  2. Wednesday, 10 August 2022 17:36 PM UTC
  1. Helpful 2
  1. John Fauss
  2. Wednesday, 10 August 2022 19:34 PM UTC
Nice, Mark! Spot on.

Tracy, the External Function Declaration for the GetBinaryTypeW API is easy to define... First argument is a PB String, the 2nd is a PB Ref ULong, returns PB Boolean. The API function resides in Kernel32.dll.
  1. Helpful 2
  1. Mark Goldsmith
  2. Wednesday, 10 August 2022 20:53 PM UTC
Thanks John. If Tracy is sending mail via mailSend and the mailSession object then I would lean towards using this API to discern the bitness (and thanks for adding the argument details). If Tracy is already connecting to Outlook via OLE to send mail then I would lean towards my third option. If it turns out the bitness is not an issue, simply continue on with the OLE code/ commands. If not, notify the user and destroy the OLE object.
  1. Helpful 1
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Wednesday, 10 August 2022 14:58 PM UTC
  2. PowerBuilder
  3. # 2

If you can read outlook.exe into a blob, there is a simple way to check.

Somewhere between position 250 and 500 are the letters 'PE'. 3 bytes after that, a 64bit app has a lower case d. A 32bit app has an upper case L. These letters are all Ansi. You can loop through the blob looking at the value of each byte until you find it.

The Asc number for d = 100 and L = 76.

Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Wednesday, 10 August 2022 14:14 PM UTC
  2. PowerBuilder
  3. # 3

Tracy -

Read through the entire discussion thread from StackOverflow, as it covers your topic and mentions different versions of Office, including Office 365.

   https://stackoverflow.com/questions/2203980/detect-whether-office-is-32bit-or-64bit-via-the-registry

It should help you determine what keys/values to check in the Registry to accomplish your goal.

John

Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Wednesday, 10 August 2022 02:41 AM UTC
  2. PowerBuilder
  3. # 4

Hi, Tracy - 

I can't speak to later versions of Office/Outlook or Office-365, but for Office 2016:

I looked in the Registry at key:

  Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\16.0\Outlook

Under this key is a value named "Bitness". The value on my system is "x64".

Alternatively, you could look in the Registry for "\outlook.exe" (a path value ending with "outlook.exe"). Parse the first folder name after the drive letter. If it is "Program Files", then a 64-bit version of Outlook is installed. If it is "Program Files (x86)", it is a 32-bit version.

There are probably many other ways. Perhaps a web search will give you some additional ways to check which bitness of Outlook is installed.

Best regards, John

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.