Solved

Determine current machine app is on

Posted on 2003-11-18
2
191 Views
Last Modified: 2010-05-01
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
Comment
Question by:MrKevorkian
2 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 250 total points
ID: 9772160
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
 
LVL 1

Author Comment

by:MrKevorkian
ID: 9772292
Perfect.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VBA: Add rows to listbox based on criteria 7 73
Excel object stays open 19 71
Saving history changes to sub form 4 36
Access 2013 combo box not working 3 38
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now