CanOz Blog

Neil Knobbe's Blog at vbCity

This blog hosted by:
http://blogs.vbcity.com      
  Home :: Syndication  :: Login

JulAugust 2008Sep
SMTWTFS
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456

Archives

Image Galleries

vbCity Blogs

I figure that it is about time that I started using my Blog as a place where others can perhaps learn something about programming with Visual Basic and Visual Basic.NET.  So here goes.

 

My, Oh My

Having installed Visual Studio 2005 on my computer the other day I took the plunge and looked at some of the new features.  One of the first things I came across was the My Namespace.  Oh what a difference from VB6.  Gathering information about your computer, User, Application and so much more is now very simple.

 

Gone is the day of needing line after line of code to get the Operating System of a Computer.  One line of code is all thanks to the My Namespace. 

 

My.Computer.Info.OSFullName.ToString

 

That’s it.  It almost makes life too easy. 

 

Want to know the OS version?  One line.

 

My.Computer.Info.OSVersion.ToString

 

Also at your fingertips is the amount of Total Physical and Virtual Memory as well as Available Physical and Virutal Memory.

 

Need to know how big the Users Screen is?

 

My.Computer.Screen.Bounds.Size.ToString

 

returns the screen size/resolution.

 

Have you ever written a Program where you needed to run different code or give certain privlidges based on if the User is a System Administrator or not?  Easy Peasy.

 

If My.User.IsInRole(ApplicationServices.BuiltInRole.Administrator) = True Then

    ‘ Admin code here

Else

    ‘ Pleb code here

End If

 

Also in the My Namespace you can find out all the information about your Application.  The AssemblyName, DirectoryPath, ProductName and Title just to name a few.  One of the neat things that I saw in Application.Info was Copyright. 

 

My.Application.Info.Copyright.ToString

 

Will show you a line like:

 

Copyright © [Company Name] [Year]

 

 

I know that this just scratched the surface of the My Namespace.  I know that I will be getting plenty of use from it and will dig down deeper to see what other interesting aspects I find.

 

posted on Saturday, November 26, 2005 11:22 PM