/Home /Archive /Syndicate /Blog /Support /About /Contact  
All Visual Basic Feeds in one place!





 (Note:  As you will be able to tell this is an old post, but the information in it is still relevant today.)

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 thing I came across was the My Namespace.  Oh what a difference from VB6.  Gathering information about your Computer, User, Applicaiton and so much more is now very simple.

 

Gone is the day of needing line after line of code to get he Operationg 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 findertips in the amount of Total Physical and Virtual Memory as well as Available Physical and Virtual Memory.

 

Need to know how big hte User's 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 privileges 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.

© 2005 Serge Baranovsky. All rights reserved.
All feed content is property of original publisher. Designated trademarks and brands are the property of their respective owners.

This site is maintained by SubMain(), a division of vbCity.com, LLC