Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
Get the computer name using API....
Author:
timyjimy
E-mail:
Click to e-mail author
Submitted:
1/30/2001
Version:
VB6
Compatibility:
VB6
Category:
Windows API
Views:
16179
Get the computer name using API.
Declarations:
Declare Function getComputerName Lib "kernel32.dll" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Code:
'Put this code with a command button to see it work Private Sub cmdHostname_Click() 'Variable for computer name Dim compName As String 'Variable for error checking 1=success, 0=error Dim retVal As Long compName = space(255) retVal = getComputerName(compName, 255) If retVal = 0 Then MsgBox "Could not get computer name." Exit Sub End If 'Remove the null character from the end compName = Left(compName, InStr( compName, vbNullChar) - 1) Form1.Caption = compName End Sub
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement