|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
"Environ" function in VB returns operating system environment variable.
Eg: 1. Environ("computerName") 'Displays Computer name Or Environ(5) 'Also displays computer name ~~~~~~~~~~~~~~~~~~~~~~ Public Sub printEnvironmentVariables() Dim i As Integer For i = 1 To 33 Debug.Print Environ(i) Next i End Sub ~~~~~~~~~~~~~~~~~~~~~~ Result ==== ALLUSERSPROFILE=C:\Documents and Settings\All Users APPDATA=C:\Documents and Settings\bbaskara\Application Data CLIENTNAME=Console CommonProgramFiles=C:\Program Files\Common Files COMPUTERNAME=BENOY-RAJ ComSpec=C:\WINDOWS\system32\cmd.exe HOMEDRIVE=C: HOMEPATH=\Documents and Settings\benoy LOGONSERVER=\\PILOT03 NUMBER_OF_PROCESSORS=1 OS=Windows_NT Path=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\Sys tem32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\BINN;C:\MSSQL7\BINN;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\ PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WS F;.WSH PROCESSOR_ARCHITECTURE=x86 PROCESSOR_IDENTIFIER=x86 Family 6 Model 7 Stepping 3, GenuineIntel PROCESSOR_LEVEL=6 PROCESSOR_REVISION=0703 ProgramFiles=C:\Program Files SESSIONNAME=Console SystemDrive=C: SystemRoot=C:\WINDOWS TEMP=C:\DOCUME~1\benoy\LOCALS~1\Temp TMP=C:\DOCUME~1\benoy\LOCALS~1\Temp USERDNSDOMAIN= USERDOMAIN= USERNAME=benoy USERPROFILE=C:\Documents and Settings\benoy VS80COMNTOOLS=C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\ windir=C:\WINDOWS ~~~~~~~~~~~~~~~~~~~~~~~~~~~ NOTE : In windows 98, the following function wont work to get the computer name. For eg:, environ(5) or environ("ComputerName") may be null value. So the following program helps to get the local computer name ~~~~~~~~~~~~~~~~~~~~~~~~~ Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long Private mstrComputerName As String Public Function GetTheComputerName() As String mstrComputerName = Space(250) GetComputerName mstrComputerName, Len(mstrComputerName) ' Here trimming and removing the last character of unwanted string mstrComputerName = Mid(Trim$(mstrComputerName), 1, Len(Trim$(mstrComputerName)) - 1) GetTheComputerName = mstrComputerName End Function Private Sub Form_Load() GetTheComputerName End Sub ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If any issues or suggestions, contact me @ binoy_rb@hotmail.com thanks Binoy Last edited by benoyraj : May 4th, 2004 at 12:05 PM. Reason: Windows 98 compatibility for finding computer name |
|
#2
|
|||
|
|||
|
Is there a question here?
__________________
====== Doug G ====== I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Find Computer name - or Listing of all environment function display |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|