Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 199
  • Last Modified:

Determine current machine app is on

can a vb6 application work out what machine it is currently running on

ie can it query the OS to find a UNC path:

\\MYPC


I am after some code!
thanks



0
MrKevorkian
Asked:
MrKevorkian
1 Solution
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
If you need the computer name then:

Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Private Sub Form_Load()
    Dim compName As String
    Dim result As Long
   
    compName = String(255, Chr$(0))
    result = GetComputerName(compName, 255)
    If result = 0 Then
        MsgBox "Unable to retrieve Computer Name"
    Else
        compName = Left(compName, InStr(compName, Chr$(0)) - 1)
        MsgBox "Computer Name: " & compName
    End If
End Sub
0
 
MrKevorkianAuthor Commented:
Perfect.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now