Skip to sidebar Skip to content
Ipercube Technical
Jack of all trades, master of none
Date: Time: - Stardate:
Welcome, Log in by clicking  Here!
SS64
MDN
Stack
Code
GitHub
Wiki
Convert
V Studio
  • Home
  • VB Functions
    • Access Functions
    • Assembly Info
    • Color/Image Functions
    • Data Table Functions
    • Email Functions
    • Active Directory Functions
    • LDAP Functions
    • Excel Functions
    • Logging Functions
    • Source Code Retrieval
    • String Functions
    • Sql Functions
    • Object Utilities Functions
    • System and Utilities
    • Utility Forms
  • VB Classes
    • Environment Variables Helper
  • ABAP
    • ABAP Reports
    • ABAP HTTP Functions
Ipercube Technical
  • Home
  • VB Functions
    • Access Functions
    • Assembly Info
    • Color/Image Functions
    • Data Table Functions
    • Email Functions
    • Active Directory Functions
    • LDAP Functions
    • Excel Functions
    • Logging Functions
    • Source Code Retrieval
    • String Functions
    • Sql Functions
    • Object Utilities Functions
    • System and Utilities
    • Utility Forms
  • VB Classes
    • Environment Variables Helper
  • ABAP
    • ABAP Reports
    • ABAP HTTP Functions

Get Assembly Platform

Determines the target platform of a given .NET assembly (e.g., x64, x86, AnyCPU).

This function uses GetPEKind to analyze the assembly’s PE header and determine platform characteristics:

  • Returns “x64” if compiled for AMD64 or IA64, or if PE32Plus is set.
  • Returns “x86” if Required32Bit is set.
  • Returns “AnyCPU” if the assembly is IL-only and not restricted to 32-bit.
VB
    Public Function GetAssemblyPlatform(assembly As Reflection.Assembly) As String

        Try
            Dim peKind As Reflection.PortableExecutableKinds
            Dim machine As Reflection.ImageFileMachine
            assembly.ManifestModule.GetPEKind(peKind, machine)

            ' If the header is PE32+ or the machine is AMD64 or IA64, it's 64-bit.
            If (peKind And Reflection.PortableExecutableKinds.PE32Plus) <> 0 OrElse
                machine = Reflection.ImageFileMachine.AMD64 OrElse
                machine = Reflection.ImageFileMachine.IA64 Then
                Return "x64"
            End If

            ' If flag Required32Bit is set, the assembly is forced to 32-bit.
            If (peKind And Reflection.PortableExecutableKinds.Required32Bit) <> 0 Then
                Return "x86"
            End If

            ' If the assembly is IL-only, it's AnyCPU.
            If (peKind And Reflection.PortableExecutableKinds.ILOnly) <> 0 Then
                Return "AnyCPU"
            End If

            Return "Unknown"
        Catch ex As Exception
            Console.WriteLine("Errore during assembly analysis: " & ex.Message)
            Return "Unknown"
        End Try
    End Function

Posted by ipercube


© 2026 Ipercube Design