Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old August 11th, 2006, 06:45 AM
Vincent
Guest
 
Posts: n/a
Default 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 NetConnectionEnum 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

  #2  
Old August 11th, 2006, 10:25 AM
Nick 'The database Guy'
Guest
 
Posts: n/a
Default Re: Determine Computer Name That is Accessing File

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 apiGetComputerName Lib "kernel32" Alias
"GetComputerNameA" (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 = apiGetComputerName(strCompName, lngLen)
If lngX <0 Then
GetMachineName = Left$(strCompName, 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:
Quote:
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 NetConnectionEnum 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
  #3  
Old August 11th, 2006, 02:35 PM
Vincent
Guest
 
Posts: n/a
Default Re: Determine Computer Name That is Accessing File

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:
Quote:
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 apiGetComputerName Lib "kernel32" Alias
"GetComputerNameA" (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 = apiGetComputerName(strCompName, lngLen)
If lngX <0 Then
GetMachineName = Left$(strCompName, 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:
Quote:
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 NetConnectionEnum 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
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles