netAboutBox

Overview

The AboutBox is the window that shows information about the author of a program. Usually it is the company logo, address, company hyperlink and the version of the software. Depending on the complexity of the program additional information about the user's machine, operating system, .NET and the APL interpreter may be added for troubleshooting help. This Wiki is about providing snippets of code useful in building such an AboutBox when using Dyalog APL.

Machine Information

      ⎕USING ← 'System,mscorlib.dll'
      Environment.MachineName
      Environment.UserName
      Environment.ProcessorCount
      GC.GetTotalMemory 0

      ⎕USING ← 'System.Windows,WPF/PresentationFramework.dll'
      SystemParameters.PrimaryScreenHeight
      SystemParameters.PrimaryScreenWidth

The following expression will give a multitude of information:

      ⊃{⎕ML←3 ⋄ (⍵≠'=')⊂⍵}¨⎕CMD 'set'

 r←DisplayIPAddress;address;network;networkInterfaces;properties;⎕USING
⍝ Get the Local IP Addresses
⍝ Based on: http://blog.stephencleary.com/2009/05/getting-local-ip-addresses.html
⍝ r     = 2 column matrix
⍝ r[;1] = IP Address
⍝ r[;2] = Network Name

 ⎕USING←'System.Net.NetworkInformation,System.dll' 'System.Net,System.dll' 'System.Net.Sockets,System.dll'

 r←0 2⍴'' ⍝ Initial value

⍝ Get a list of all network interfaces (usually one per network card, dialup, and VPN connection)
 networkInterfaces←NetworkInterface.GetAllNetworkInterfaces

 :For network :In networkInterfaces

   ⍝ Read the IP configuration for each network
     properties←network.GetIPProperties

    ⍝ Each network interface may have multiple IP addresses
     :For address :In properties.UnicastAddresses

       ⍝ We're only interested in IPv4 addresses for now
         :If address.Address.AddressFamily≢AddressFamily.InterNetwork
             :Continue

       ⍝ Ignore loopback addresses (e.g., 127.0.0.1)
         :ElseIf IPAddress.IsLoopback(address.Address)
             :Continue

       ⍝ Catenate the result
         :Else
             r⍪←address.Address.ToString network.Name

         :EndIf
     :EndFor
 :EndFor

 r←InternetConnected;IC
⍝ 1 if the Internet is there
 'IC'⎕NA'I WinINet|InternetGetConnectedState I I'
 r←IC 0 0

OS Information

Look at WinSys for information about the operating system.

      ⎕USING ← 'System,mscorlib.dll'
      Environment.OSVersion

.NET Information

 v←GetNetVersion;DI;dir;dirs;⎕USING
 ⍝ Function to Get the Latest .Net Framework Installed on this Computer
 ⍝ Based on: http://msdn.microsoft.com/en-us/library/y549e41e.aspx
 ⍝ v = Latest Version Installed

 ⍝ v = 0, When There is no Version of .Net Installed

 :Trap 0
     ⎕USING←'System,mscorlib.dll' 'System.IO,mscorlib.dll'
     dir←Environment.ExpandEnvironmentVariables(⊂'%WINDIR%\Microsoft.NET\Framework')
     DI←⎕NEW DirectoryInfo(⊂dir)             ⍝ Get the DirectoryInfo Object for the Directory
     dirs←DI.GetDirectories(⊂'v*')           ⍝ v* is the filter
     dirs←1↓¨dirs.Name                       ⍝ To remove the letter 'v' at the beginning of each directory
     v←+/¨(⊂1 0.1)ר2↑¨⊃¨(//¨'.'⎕VFI¨dirs)   ⍝ To Add the first 2 numbers of each directory
     v←1↑∪v[⍒v]                              ⍝ To order the directory names as numbers and return the highest number
 :Else
    ⍝ There is no .Net installed
     v←0
 :EndTrap

 r←GetCurrentLanguage;⎕USING
 ⎕USING←'System.Windows.Markup,PresentationCore.dll' 'System.Threading,mscorlib.dll'
 r←XmlLanguage.GetLanguage(⊂Thread.CurrentThread.CurrentCulture.Name)

APL Information

      '.' ⎕WG 'APLVersion'                  ⍝ Version of the APL interpreter
      +2 ⎕NQ '.' 'GetEnvironment' 'MAXWS'   ⍝ Workspace size
      +2 ⎕NQ '.' 'GetEnvironment' 'dyalog'  ⍝ Directory of the APL interpreter
      ⎕WSID                                 ⍝ Directory and name of the Workspace
      ⎕WA                                   ⍝ Number of bytes of memory available in the WS

 r←GetAssemblies;assemblies;assembly;inter;⎕USING
 ⍝ Show the Current .Net assemblies that are loaded.
 ⍝ Returns a 3 column matrix representing the name, version and location of the assembly loaded.
 ⍝ Inspired from: http://www.dyalog.com/forum/viewtopic.php?f=35&t=990

 r←0 3⍴⍬

 ⎕USING←'System' 'System.Diagnostics,system.dll'

 :Trap 0
     assemblies←AppDomain.CurrentDomain.GetAssemblies

     :For assembly :In assemblies

         :If assembly.IsDynamic
             inter←2↑(~inter=',')⊂inter←assembly.ToString
             r⍪←inter,⊂'Dynamic assembly with no location'
         :Else
             inter←1↑(~inter=',')⊂inter←assembly.ToString
             inter,←⊂(FileVersionInfo.GetVersionInfo(⊂assembly.Location)).FileVersion
             r⍪←inter,⊂assembly.Location
         :EndIf
     :EndFor

 :Else
    ⍝ If ⎕USING←0⍴⊂'', it will bug.
     r←0 3⍴⍬
 :End

 r←GetSyncfusionAssemblies;⎕ML;⎕USING
 ⍝ Show the Current Syncfusion assemblies that are loaded.
 ⎕USING ⎕ML←'System' 0
 :Trap 0
     r←↑⍕¨AppDomain.CurrentDomain.GetAssemblies
     r←(r[;⍳11]∧.='Syncfusion.')⌿r
 :Else
    ⍝ If ⎕USING←0⍴⊂'', it will bug.
     r←0 0⍴''
 :End

Original author:

Pierre Gilbert

Responsible:

PierreGilbert

Email:

<apgil AT SPAMFREE videotron DOT ca>


CategoryDyalog - CategoryDyalogDotNet - CategoryDotNet

netAboutBox (last edited 2016-03-21 10:56:58 by PierreGilbert)