Bueno esta función usa el PID del programa y busca el PID del programa padre, si resulta que el programa padre es gambas (gbr3) entonces estamos en entorno IDE si resulta que no estamos ejecutando el programa desde el escritorio.
Dejo un ejemplo para verlo en mas detalle.
Public Function Werun(strProc1 As String) As Integer '' Devuelve si el programa se ejecuta desde el ide o no
Dim strProcRaw1 As String
Dim strPProc As String
Dim strProcRaw2 As String
Dim intMode As Integer
' Averiguar el PPID
strProcRaw1 = ""
Shell "ps -ef | grep " & strProc1 & " | grep gbx3" To strProcRaw1
strProcRaw1 = Replace(strProcRaw1, "\t", "|")
strProcRaw1 = Replace(strProcRaw1, " ", "|")
strProcRaw1 = Replace(strProcRaw1, "||", "|")
strProcRaw1 = Replace(strProcRaw1, "||", "|")
strProcRaw1 = Replace(strProcRaw1, "||", "|")
'Shell "ps -ef | grep " & strProc1 & " | grep gbx3 | cut -d ''-f2" To strPProc
If strProcRaw1 <> "" Then
strPProc = Split(strProcRaw1, "|")[2]
'Averiguar el nombre del programa padre
Shell "ps -ef | grep " & strPProc & " | grep gbr3" To strProcRaw2
strProcRaw2 = Replace(strProcRaw2, " ", " ")
strProcRaw2 = Replace(strProcRaw2, "\t", "|")
strProcRaw2 = Replace(strProcRaw2, " ", "|")
strProcRaw2 = Replace(strProcRaw2, "||", "|")
strProcRaw2 = Replace(strProcRaw2, "||", "|")
strProcRaw2 = Replace(strProcRaw2, "||", "|")
If strProcRaw2 <> "" Then
If Split(strProcRaw2, "|")[1] = strPProc Then
intMode = 1 ' Se esta ejecutando desde el IDE
Else
intMode = 0 ' Se esta ejecutando desde un paquete
Endif
Endif
Endif
Return intMode
End
Dim strProcRaw1 As String
Dim strPProc As String
Dim strProcRaw2 As String
Dim intMode As Integer
' Averiguar el PPID
strProcRaw1 = ""
Shell "ps -ef | grep " & strProc1 & " | grep gbx3" To strProcRaw1
strProcRaw1 = Replace(strProcRaw1, "\t", "|")
strProcRaw1 = Replace(strProcRaw1, " ", "|")
strProcRaw1 = Replace(strProcRaw1, "||", "|")
strProcRaw1 = Replace(strProcRaw1, "||", "|")
strProcRaw1 = Replace(strProcRaw1, "||", "|")
'Shell "ps -ef | grep " & strProc1 & " | grep gbx3 | cut -d ''-f2" To strPProc
If strProcRaw1 <> "" Then
strPProc = Split(strProcRaw1, "|")[2]
'Averiguar el nombre del programa padre
Shell "ps -ef | grep " & strPProc & " | grep gbr3" To strProcRaw2
strProcRaw2 = Replace(strProcRaw2, " ", " ")
strProcRaw2 = Replace(strProcRaw2, "\t", "|")
strProcRaw2 = Replace(strProcRaw2, " ", "|")
strProcRaw2 = Replace(strProcRaw2, "||", "|")
strProcRaw2 = Replace(strProcRaw2, "||", "|")
strProcRaw2 = Replace(strProcRaw2, "||", "|")
If strProcRaw2 <> "" Then
If Split(strProcRaw2, "|")[1] = strPProc Then
intMode = 1 ' Se esta ejecutando desde el IDE
Else
intMode = 0 ' Se esta ejecutando desde un paquete
Endif
Endif
Endif
Return intMode
End
Saludos.
ejercicio-ejecucion-0.0.2.tar.gz | ||
Descripción: | Descargar |
|
Nombre del archivo: | ejercicio-ejecucion-0.0.2.tar.gz | |
Tamaño: | 12.04 KB | |
Descargado: | 40 veces |
ejercicio-ejecucion-0.0.2.tar.gz | ||
Descripción: | Descargar |
|
Nombre del archivo: | ejercicio-ejecucion-0.0.2.tar.gz | |
Tamaño: | 12.04 KB | |
Descargado: | 40 veces |
ejercicio-ejecucion-0.0.2.tar.gz | ||
Descripción: | Descargar |
|
Nombre del archivo: | ejercicio-ejecucion-0.0.2.tar.gz | |
Tamaño: | 12.04 KB | |
Descargado: | 40 veces |