![]() |
Languages »
VBScript »
General
Intermediate
How to get Windows Directory, Computer Name and System Information detailsBy benoyrajThis small program demonstrates to how to get the windows directory path name, Computer Name, and System information details |
VBScript, VB 6, .NET, Win2K, WinXP, Win2003, Dev
|
||||||||
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||

The utiltity helps you to understand how to return computer system name/windows system path and system information from a windows system (95,98,NT and XP).
You have to include the following system DLL files into your application.
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Declare Function GetWindowsDirectory Lib "kernel32.dll" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
The following GetTheComputerName function returns the computer name from your system. See how the code works with System DLL file.
Public Function GetTheComputerName() As String
Dim strComputerName As String ' Variable to return the path of computer name
strComputerName = Space(250) ' Initilize the buffer to receive the string
GetComputerName strComputerName, Len(strComputerName)
strComputerName = Mid(Trim$(strComputerName), 1, Len(Trim$(strComputerName)) - 1)
GetTheComputerName = strComputerName
End Function
The following GetTheWindowsDirectory function returns the windows system path from your system. See how the code works with System DLL file.
Public Function GetTheWindowsDirectory() As String
Dim strWindowsDir As String ' Variable to return the path of Windows Directory
Dim lngWindowsDirLength As Long ' Variable to return the the lenght of the path
strWindowsDir = Space(250) ' Initilize the buffer to receive the string
lngWindowsDirLength = GetWindowsDirectory(strWindowsDir, 250) ' Read the path of the windows directory
strWindowsDir = Left(strWindowsDir, lngWindowsDirLength) ' Extract the windows path from the buffer
GetTheWindowsDirectory = strWindowsDir
The following lines of code will display all the system environment variables in a text box.
Dim intInc As Integer
Dim strDisplay As String
Text1 = ""
' Here we start printing
For intInc = 1 To 35
strDisplay = strDisplay & Environ(intInc)
strDisplay = strDisplay & Space(5)
Next intInc
Text1 = strDisplay
This small program demonstrates how to call the system functions from the windows DLL file and implement into your system. From this program you found how to call GetComputerName and GetWindowsSystemDirectoryPath informations. Also, you identified the importance of System information using Environ variables. I hope this will helps you if you dont have any prior knowledge of system handle functions.
Benoyraj B
| You must Sign In to use this message board. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 17 May 2004 Editor: |
Copyright 2004 by benoyraj Everything else Copyright © CodeProject, 1999-2009 Web17 | Advertise on the Code Project |