Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Determine all current Win process
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01064064
Message ID:
01064462
Views:
194
>>Sergey,
>>
>Intellisense does not work with WMI, I ignore why.
>
>To see the properties and methods, it is right there in Sergey's link, you should look at Win32 classes, for example:
>
>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/getowner_method_in_class_win32_process.asp

Thanks Hugo:
I'm trying the code in the last link
strComputer = "."
Set colProcesses = GetObject("winmgmts:" & _
   "{impersonationLevel=impersonate}!\\" & strComputer & _
   "\root\cimv2").ExecQuery("Select * from Win32_Process")

For Each objProcess in colProcesses

    Return = objProcess.GetOwner(strNameOfUser)
    If Return <> 0 Then
        Wscript.Echo "Could not get owner info for process " & _  
            objProcess.Name & VBNewLine _
            & "Error = " & Return
    Else 
        Wscript.Echo "Process " _
            & objProcess.Name & " is owned by " _ 
            & "\" & strNameOfUser & "."
    End If
Next
in VFP it looks like this:
strComputer = "."
loCIMV2 = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" + strComputer + "\root\cimv2")
colProcesses = loCIMV2.ExecQuery("Select * from Win32_Process")

For Each objProcess in colProcesses
	strNameOfUser = SPACE(140)
    Return = objProcess.GetOwner(strNameOfUser)
    If Return <> 0 Then
        ? "Could not get owner info for process " + objProcess.Name + CHR(13) + "Error = " + STR(Return)
    Else 
        IF objProcess.name = "WINWORD"
        	SET STEP ON 
        ENDIF 	
        ? "Process " + objProcess.Name + " is owned by " + "\" + strNameOfUser + "."
    EndIf
Next
I'm not sure the first example works "as is" as the variable "strNameOfUser" was not declared, the help says the "GetOwner" method has 2 "output" variables. Anyhow ;), it's not working, the strNameOfUser is never filled althought the method call returns 0 (success). I tried pre-filling it with null, 0, "" and a x number of spaces, it remains untouched.
Do you know how to proceed from here?

TIA

Max

...Y soy feliz, bien feliz, asi lo grito;
Mira, que el mundo sepa, que se sepa:
Soy feliz....                       

...And I'm happy, quite happy, so do I yell it;
Look, so the world knows it, so be known:
I'm happy...
 

Ismael Rivera "Oye cosita linda"
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform