Results 1 to 7 of 7

Thread: [RESOLVED] Programmatically detect if MS Office is 64 Bit or 32 Bit

  1. #1

    Thread Starter
    Addicted Member Kram Kramer's Avatar
    Join Date
    Dec 2016
    Posts
    131

    Resolved [RESOLVED] Programmatically detect if MS Office is 64 Bit or 32 Bit

    I have got code from this link https://stackoverflow.com/questions/...using-registry
    The code is supposed to be told you if your MS Office product is 64 Bit or 32 Bit.

    My question is here:
    I am not %100 sure that the code above is confidential.
    Please run the code above and tell me if the code above gives correct result for your MS Office product.

    If you have any other code better than above code please post here.

    Thanks in advance
    Last edited by Kram Kramer; Nov 7th, 2018 at 07:31 AM.

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    107,648

    Re: Programmatically detect if MS Office is 64 Bit or 32 Bit

    Quote Originally Posted by Kram Kramer View Post
    I am not %100 sure that the code above is confidential.
    I think that there may be a language issue here. "Confidential" means "secret" and I don't think that that's what you mean there. Are you trying to say that you're not 100% confident that the code will always work?

  3. #3

    Thread Starter
    Addicted Member Kram Kramer's Avatar
    Join Date
    Dec 2016
    Posts
    131

    Re: Programmatically detect if MS Office is 64 Bit or 32 Bit

    Quote Originally Posted by jmcilhinney View Post
    Are you trying to say that you're not 100% confident that the code will always work?
    Yes, I am trying to say that I am not 100% confident that the code will always work

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    107,648

    Re: Programmatically detect if MS Office is 64 Bit or 32 Bit

    It appears to be based on the application product code so, as long as Microsoft don't change the format they use for that, you should be safe. I don't know what that format is specifically but maybe you ought to research that.

  5. #5

    Thread Starter
    Addicted Member Kram Kramer's Avatar
    Join Date
    Dec 2016
    Posts
    131

    Re: Programmatically detect if MS Office is 64 Bit or 32 Bit

    Hi jmcilhinney,
    Please check following link and tell me if the codes in the following link could be used for Winform/vb.net application?
    https://docs.microsoft.com/tr-tr/off...tions-overview

  6. #6
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    107,648

    Re: Programmatically detect if MS Office is 64 Bit or 32 Bit

    Is it VB.NET code? No, it's VBA code, so it can be used for VBA, not VB.NET.

  7. #7
    Lively Member
    Join Date
    Jan 2013
    Posts
    124

    Re: [RESOLVED] Programmatically detect if MS Office is 64 Bit or 32 Bit

    Quote Originally Posted by Kram Kramer View Post
    If you have any other code better than above code please post here.
    Hi, Here's my hack. I have been using it for a while and it works fine with different versions/platforms. It checks the PE header so it works with any portable executable (exe,dll...).
    Code:
    Imports System.IO
    Imports Microsoft.Win32
    
    Public Class Form1
        Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
            Dim ExcelPath As String = CStr(Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\excel.exe", "Path", "Key does not exist")) & "EXCEL.EXE"
            If ExcelPath = "EXCEL.EXE" Then
                MessageBox.Show("No Excel installed")
                Exit Sub
            End If
            Using BR As New IO.BinaryReader(File.Open(ExcelPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                Dim fPos As Integer = 0
                Dim fLen As Integer = CInt(BR.BaseStream.Length)
                While fPos < fLen - 5
                    Dim B1, B2, B3, B4, B5, B6 As Byte
                    B1 = BR.ReadByte()
                    B2 = BR.ReadByte()
                    B3 = BR.ReadByte()
                    B4 = BR.ReadByte()
                    B5 = BR.ReadByte()
                    B6 = BR.ReadByte()
                    Dim FileSig As String = B1 & B2 & B3 & B4 & B5 & B6
                    Select Case FileSig
                        Case "806900761"
                            MessageBox.Show("File is 32 bit")
                            fPos = fLen
                        Case "806900100134"
                            MessageBox.Show("File is 64 bit")
                            fPos = fLen
                    End Select
                    fPos += 1
                    BR.BaseStream.Seek(-5, SeekOrigin.Current)
                End While
            End Using
        End Sub
    End Class
    Hope that helps.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width