473,810 Members | 3,137 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Finding the current computer name in VB?

Hello,

Is there a way to find the current machine name using VB? I'm trying to log
user activity, but I'd also like to log the location as well i.e. if errors
occur, then I can get an idea what machine the user was on when the
exception was thrown in case that has anything to do with the issue.

Any help would be great! Thanks!
Nov 13 '05 #1
2 4491
This works fine for me http://www.mvps.org/access/api/api0009.htm

"Jozef" <SP**********@t elus.net> wrote in message
news:ZO%Se.9407 0$Hk.62070@pd7t w1no...
Hello,

Is there a way to find the current machine name using VB? I'm trying to
log user activity, but I'd also like to log the location as well i.e. if
errors occur, then I can get an idea what machine the user was on when the
exception was thrown in case that has anything to do with the issue.

Any help would be great! Thanks!

Nov 13 '05 #2
"Jozef" <SP**********@t elus.net> wrote in message
news:ZO%Se.9407 0$Hk.62070@pd7t w1no...
Hello,

Is there a way to find the current machine name using VB? I'm trying to log user activity, but I'd also like to log the location as well i.e. if errors occur, then I can get an idea what machine the user was on when the
exception was thrown in case that has anything to do with the issue.

Any help would be great! Thanks!

Paste the following code into a new module:

'--------------------< begin code >--------------------
Private Declare Function GetComputerName A Lib "kernel32" _
(ByVal lpBuffer As String, nSize As Long) As Long

Public Function CurrentMachineN ame() As String
Dim lSize As Long
Dim sBuffer As String
sBuffer = Space$(16)
lSize = Len(sBuffer)

If GetComputerName A(sBuffer, lSize) Then
CurrentMachineN ame = Left$(sBuffer, lSize)
End If

End Function

'---------------------< end code >---------------------

Now you can retrieve the current machine name with CurrentMachineN ame().
Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
6574
by: Victor Engmark | last post by:
When looking for a method to fetch unique elements and counting the number of occurences of each of them, I found quite a lot of gross examples of complex XSL. But after realizing the subtle difference between "." and "current()", I found a neat way of doing the same without keys or generate-id(): <xsl:template match="/"> <!-- Selects all "new" elements --> <xsl:for-each select="//Name"> <!-- Display the element -->
2
2835
by: Ginu | last post by:
Hi, the task is to identify semantically identical elements where some additional attributes do not match. The XSL-transformation should find a node NAME which @id attribute matches to another NAME/@id in the document tree and additionally a specific further conditions holds (@cid's shouldn't be the same). For that I would like to refer to the node selected in the "following" axes, but I do not know how to refer to this...
4
4731
by: Porthos | last post by:
Hi All, I'm trying to find the minimum value of a set of data (see below). I want to compare the lengths of these attribute values and display the lowest one. This would be simple if I could re-assign values to a variable, but from what I gather I can't do that. How do I keep track of the lowest value as I loop through? My XSL document only finds the length of each string and prints it out (for now). I can write a template
7
3824
by: Ewart MacLucas | last post by:
Does anybody know how to find the workgroup name (or domainname) of the local PC. Is there a framework class for it? (preferably a solution not involving active directory calls) Thanks, Ewart.
7
1911
by: Jason Reichenbach | last post by:
I've GOT to be missing something painfully obvious, here... I need to programmatically get the full human name of the current user on a local system, the same system upon which the app is running. Using C#.NET MSDEV2003. OS will be Win2K or WinXP. I've found numerous ways to get the user name, but have yet to find the way to get the human name.
9
12574
by: dave m | last post by:
I need to be able to retrieve a unique ID from a users PC. I needs to be something a user could not easily change, like the computer name. Could someone point me in the right direction to find the information found in Windows system information? Or maybe there is a better method. Thanks in advance for any help or suggestions. Dave M.
3
12746
by: Rico | last post by:
Hello, I have a generic process that logs errors from different sources. When I call this code, I'd like to also submit the name of the function or sub that is raising the error without having to manually type this in for each instance. For instance, (air code to follow) Public Sub LogMyError( errNumber as int, errDescription as string, SubFuncName as string)
3
1772
nomad
by: nomad | last post by:
When I run choice == 2 I'm suppose to a an out.println back finding a product. but I get Null for all the values. Can someone help me with this. class Computer_listing { private String id; private String name;
275
12442
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
0
10644
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10379
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10393
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7664
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5690
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4334
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3863
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.