473,769 Members | 1,882 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 4523
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
41601
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
2231
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
1160
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
2570
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 ver. 1.0.3705 is installed Dot Net Framework ver. 1.1.4322 is installed
40
2994
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 safe to compact the back-end files without going round to make sure everyone is logged off. User...
0
12087
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
4222
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 static-different machine. for this purpose I need to create a Remote Connection from my
4
6851
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 administrator on the remote computer also.I'm providing the domain name,remote computer name,userID...
1
1657
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") 'IPHost = Dns.Resolve("ASHEESH") s1 = IPHost.HostName.ToString ...
0
9416
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10199
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
8861
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
7393
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
6661
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5433
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3948
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
3551
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2810
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.