get who is using a file

get who is using a file

Postby ukservice » Thu Feb 24, 2011 3:41 pm

Hello,

When a folder is shared, is there a function to get all the users that are using a file?.

Thank you.
FWH 11.11, Harbour 3.1 and Borland C++ 5.82
User avatar
ukservice
 
Posts: 417
Joined: Tue Feb 23, 2010 3:09 pm
Location: John

Re: get who is using a file

Postby anserkk » Fri Feb 25, 2011 6:17 am

I am not sure whether this is what you are looking for. The following code gives you a list of users of a particular exe file.
Try this
Code: Select all  Expand view

#Include "FiveWin.ch"
//-----------------------//
Function Main()
     MsgList(GetExeUsers(cFileName( HB_ARGV( 0 ) )))
Return NIL        
   
*------------------------------------*
FUNCTION GetExeUsers(cExe )
*------------------------------------*
   Local oLoc,oWmi
   Local oList, oProc
   Local cUser, cDomain
   Local aList := {}

   oLoc:= CreateObject( "wbemScripting.SwbemLocator" )
   oWmi:= oLoc:ConnectServer()
   
   IF !Empty(oWmi)
      oList := oWmi:ExecQuery( "select * from Win32_Process where Name = '" + cExe + "'" )
      FOR EACH oProc IN oList
         IF ( oProc:GetOwner( @cUser, @cDomain ) ) == 0
            cUser = cDomain + "\" + cUser
            IF AScan( aList, cUser ) == 0
               AAdd( aList, cUser )
            ENDIF
         ENDIF
      NEXT
   ENDIF

RETURN aList    


Regards
Anser
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 86 guests

cron