473,581 Members | 2,967 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Determine Computer Name That is Accessing File

I have been trying to find some API routines that will allow me to
determine the name of the computer that is accessing a file on a
server. I have found the NetFileEnum call (returns the names of the
files in use and the names of the users accessing them). I have also
found the NetConnectionEn um call (returns the name of the computer that
is accessing a share). I do not see any way of correlating the data
that these two api calls return. Can anyone point me in the right
direction? Thanks.

-Vincent

Aug 11 '06 #1
2 4504
Hi Vincent,

This function (see below) will return the name of the local computer,
if you use this routine in a client server environment you have to
place the code on the local machine.

Private Declare Function apiGetComputerN ame Lib "kernel32" Alias
"GetComputerNam eA" (ByVal lpBuffer As String, nSize As Long) As Integer

'Returns the computername
Function GetMachineName( ) As String
Dim lngLen As Long
Dim lngX As Integer
Dim strCompName As String
lngLen = 12
strCompName = String$(lngLen, 0)
lngX = apiGetComputerN ame(strCompName , lngLen)
If lngX <0 Then
GetMachineName = Left$(strCompNa me, lngLen)
Else
GetMachineName = ""
End If
End Function

If your machines have name longer than 12 characters you should adjust
the lngLen variable to for instance 18.

Good luck

Nick

It will automatically give a
Vincent wrote:
I have been trying to find some API routines that will allow me to
determine the name of the computer that is accessing a file on a
server. I have found the NetFileEnum call (returns the names of the
files in use and the names of the users accessing them). I have also
found the NetConnectionEn um call (returns the name of the computer that
is accessing a share). I do not see any way of correlating the data
that these two api calls return. Can anyone point me in the right
direction? Thanks.

-Vincent
Aug 11 '06 #2
Nick,

This is good information, but it really does not help me. I am
trying to find out the name of the computer that has a particular file
open. I need some routine that encompasses both of these pieces of
information or a way to cross-reference multiple API calls to retrieve
this information.

-Vincent

Nick 'The database Guy' wrote:
Hi Vincent,

This function (see below) will return the name of the local computer,
if you use this routine in a client server environment you have to
place the code on the local machine.

Private Declare Function apiGetComputerN ame Lib "kernel32" Alias
"GetComputerNam eA" (ByVal lpBuffer As String, nSize As Long) As Integer

'Returns the computername
Function GetMachineName( ) As String
Dim lngLen As Long
Dim lngX As Integer
Dim strCompName As String
lngLen = 12
strCompName = String$(lngLen, 0)
lngX = apiGetComputerN ame(strCompName , lngLen)
If lngX <0 Then
GetMachineName = Left$(strCompNa me, lngLen)
Else
GetMachineName = ""
End If
End Function

If your machines have name longer than 12 characters you should adjust
the lngLen variable to for instance 18.

Good luck

Nick

It will automatically give a
Vincent wrote:
I have been trying to find some API routines that will allow me to
determine the name of the computer that is accessing a file on a
server. I have found the NetFileEnum call (returns the names of the
files in use and the names of the users accessing them). I have also
found the NetConnectionEn um call (returns the name of the computer that
is accessing a share). I do not see any way of correlating the data
that these two api calls return. Can anyone point me in the right
direction? Thanks.

-Vincent
Aug 11 '06 #3

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

Similar topics

5
41558
by: Maverick | last post by:
I'm trying to get the " Computer Name " of a client accessing my web site, is there a way to do this ? not ip... tia
8
2221
by: Steven Van Dyke | last post by:
Hi I need a code snippet to determine if my computer is connected to a network or not. There's probably a System.Net function for it, but I cannot find it. Thanks, Steve
3
1149
by: Jinu | last post by:
Hello Will be very helpful if anyone can share the idea o 'how to access a computer in a LAN using .NET Thank yo Jinu.
6
2559
by: dbuchanan | last post by:
I have a Windows Forms application that accesses SQL Server 2k from a small local network. The application has been used for weeks on other systmes but a new install on a new machine retruns errors. The machine is a new laptop Windows XP Pro SP2 The machine is up to date with respect to the dot net framework. Details: Dot Net Framework...
40
2945
by: Jeff | last post by:
I have a system on a network and want to determine if anyone is currently connected to the back-end files. An interesting twist is that I have noticed that some users can be connected (have the front end open at the first form) and even though this links to the back-end files, there are no ldb files created. This is so I know when it is...
0
12065
by: sonu | last post by:
I have following client side code which i have used in my asp.net project SummaryFeatured Resources from the IBM Business Values Solution Center WHITEPAPER : CRM Done Right Improve the likelihood of CRM success from less than 20 percent to 60 percent. WHITEPAPER :
4
4207
by: Noy B | last post by:
Hi, I have developed a small application that is using a MSAccess DB. the problem is that it was developed on a machine where the application and the DB are both located. now it needs to be change that the application will be able to run on any other machine (using \\ syntax on the run command- not a problem) using the DB located on a...
4
6846
by: wickedweapon | last post by:
Hi, I'm trying to access a remote computer and view its running processes thorugh WMI by using a script on my system but i keep getting "RPC server unavailable" error.I have changed the COM settings(as mentioned in msdn library articles) many times but it still gives the same error. The account that I have used to log on to my computer is an...
1
1652
by: vabh | last post by:
Hello, My computer is connected in LAN and so many other computers too. So, now i want to access any .exe file of any other computer. Before that i am accessing the Computer Name and IPAddress of other computer using following code--- Dim s1, s2 As String Dim IPHost As IPHostEntry = Dns.GetHostEntry("ASHEESH") ...
0
7860
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7788
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8139
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. ...
1
7890
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...
0
6546
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...
0
3813
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2298
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
1
1398
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1127
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.