KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

PhysicalMemoryInfoTool - something small, something usefull

 
Post new topic   Reply to topic    KiXforms Forum Index -> KiXforms.NET Discussion
View previous topic :: View next topic  
Author Message
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Sun May 06, 2007 11:59 pm    Post subject: PhysicalMemoryInfoTool - something small, something usefull Reply with quote

Code:

$System = CreateObject("Kixforms.System")
If 9<>vartype($System)
   $nul= MessageBox("KiXforms.Net Not Installed. This Script Will Now Close.","Error",16)
   Quit
EndIf
$nul = $System.Application.EnableVisualStyles

$MainForm = $System.Form
$MainForm.FormBorderStyle = 3  ;FormBorderStyle_FixedDialog
$MainForm.MaximizeBox = 0  ;False
$MainForm.StartPosition = 2  ;FormStartPosition_WindowsDefaultLocation
$MainForm.Size = $System.Size(433,245) ;(Width,Height)
$MainForm.Text = "Physical Memory Info"

$scanName = $System.TextBox
$scanName.Left = 115
$scanName.Text = "localhost"
$scanName.Top = 20
$scanName.Width = 150
$nul = $MainForm.Controls.Add($scanName)

$scanLabel = $System.Label
$scanLabel.Height = 20
$scanLabel.Left = 10
$scanLabel.Text = "Computer to Scan:"
$scanLabel.Top = 20
$scanLabel.Width = 105
$nul = $MainForm.Controls.Add($scanLabel)

$ScanButton = $System.Button
$ScanButton.FlatStyle = 3  ;System
$ScanButton.Height = 21
$ScanButton.Left = 275
$ScanButton.Text = "Scan!"
$ScanButton.Top = 20
$ScanButton.Click = "FillTheView"
$nul = $MainForm.Controls.Add($ScanButton)

$ScanResults = $System.ListView
$ScanResults.FullRowSelect = -1  ;True
$ScanResults.HeaderStyle = 1  ;Nonclickable
$ScanResults.Height = 140
$ScanResults.Left = 10
$ScanResults.Scrollable = 0  ;False
$ScanResults.Sorting = 1  ;Ascending
$ScanResults.Top = 55
$ScanResults.Width = 405
$ScanResults.View = $System.View_Details
$nul = $MainForm.Controls.Add($ScanResults)

$ScanResultsColumn0 = $ScanResults.Columns.Add($System.ColumnHeader("Slot",80,$System.HorizontalAlignment_Left))
$ScanResultsColumn1 = $ScanResults.Columns.Add($System.ColumnHeader("Size, Mb",50,$System.HorizontalAlignment_Right))
$ScanResultsColumn2 = $ScanResults.Columns.Add($System.ColumnHeader("Speed, MHz",75,$System.HorizontalAlignment_Right))
$ScanResultsColumn3 = $ScanResults.Columns.Add($System.ColumnHeader("Casing",60,$System.HorizontalAlignment_Left))
$ScanResultsColumn4 = $ScanResults.Columns.Add($System.ColumnHeader("Type",70,$System.HorizontalAlignment_Left))
$ScanResultsColumn5 = $ScanResults.Columns.Add($System.ColumnHeader("DataWidth",70,$System.HorizontalAlignment_Right))


$MainForm.AcceptButton = $ScanButton
$MainForm.Show  ;Displays the Form

While $MainForm.Visible
   $Nul = Execute($MainForm.DoEvents)
Loop
Exit 0

Function FillTheView()
dim $memModule,$row, $
 $ScanResults.Items.Clear
 for each $memModule in PhysicalMemoryInfo($scanName.Text)
  $row = $ScanResults.Items.Add($System.ListViewItem($memModule[0]))
  $ = $row.SubItems.Add($System.ListViewSubItem($memModule[1]))
  $ = $row.SubItems.Add($System.ListViewSubItem($memModule[4]))
  $ = $row.SubItems.Add($System.ListViewSubItem($memModule[2]))
  $ = $row.SubItems.Add($System.ListViewSubItem($memModule[3]))
  $ = $row.SubItems.Add($System.ListViewSubItem($memModule[5]))
 next
EndFunction

;Function:
;        PhysicalMemoryInfo()
;
;Author:
;        Jooel
;
;Version:
;        1.0
;
;Version History:
;        1.0 - Mon, May 7, 2007 - original release
;
;Action:
;        Retrieves physical memory module info, local or remote.
;
;Syntax:
;        PhysicalMemoryInfo([COMPUTER])
;
;Parameters:
;        COMPUTER - Optional. Remote computer from which to gather the info
;
;Returns:
;        Array in which each element contains array of 6-elements:
;         0 - Physical Location
;         1 - Capacity, in Mb's
;         2 - Form Factor
;         3 - Memory Type
;         4 - Speed, MHz
;         5 - Data Width
;
;Remarks:
;        Couldn't find anything like it already published.
;        Should be quite usefull for inventory and stuff.
;
;Example:
;        "Memory info on local computer:" ?
;        "Location   Capacity   Speed" ?
;        For each $memModule in PhysicalMemoryInfo("localhost")
;         $memModule[0] chr(9) chr(9) $memModule[1] chr(9) chr(9) $memModule[4] ?
;        Next
;        ? "Done."
;        get $
;
;Source:
Function PhysicalMemoryInfo(optional $sComp)
dim $fF,$mT,$oWMI,$oM,$tMem[0]

 if not $sComp
  $sComp = "."
 endif
 $fF="Unknown","Other","SIP","DIP","ZIP","SOJ","Proprietary","SIMM","DIMM","TSOP","PGA",
  "RIMM","SODIMM","SRIMM","SMD","SSMP","QFP","TQFP","SOIC","LCC","PLCC","BGA","FPBGA","LGA"
 $mT="Unknown","Other","DRAM","Synchronous DRAM","Cache DRAM","EDO","EDRAM","VRAM","SRAM",
  "RAM","ROM","Flash","EEPROM","FEPROM","EPROM","CDRAM","3DRAM","SDRAM","SGRAM","RDRAM","DDR"

 $oWMI = GetObject("winmgmts:\\" + $sComp + "\root\cimv2")
 if @error exit @error endif
 For each $oM in $oWMI.ExecQuery("Select * from Win32_PhysicalMemory",,48)
  $tMem[ubound($tMem)]=$oM.DeviceLocator,1 * $oM.Capacity / 1048576,
  $fF[$oM.FormFactor], $mT[$oM.MemoryType], $oM.Speed,$oM.DataWidth
  redim preserve $tMem[ubound($tMem)+1]
 Next
 if 0<ubound($tMem)
  redim preserve $tMem[ubound($tMem)-1]
 endif
 $PhysicalMemoryInfo=$tMem
EndFunction

_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
benny69
KiXforms Advocate
KiXforms Advocate


Joined: 30 Oct 2003
Posts: 567
Location: Lincoln, Ne

PostPosted: Mon May 07, 2007 12:12 pm    Post subject: Reply with quote

Nice! Thanks Lonk, good to see you doing some KiXforming.
_________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)
Back to top
View user's profile Send private message Send e-mail
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Mon May 07, 2007 1:56 pm    Post subject: Reply with quote

if it wasn't for KFD, I would have never taken the time to code this.

so, thank you! Wink

_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
pearly
KiXforms Aficionado
KiXforms Aficionado


Joined: 27 Jan 2004
Posts: 332

PostPosted: Mon May 07, 2007 10:35 pm    Post subject: Reply with quote

Awesome tool, Lonk. This motivates me to really get going in my KF.NET development.

Cheers!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> KiXforms.NET Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group