|
51
|
Programación / Programación Visual Basic / IsWay
|
en: 22 Mayo 2011, 00:08 am
|
Option Explicit
'Author: Sergio Desanti 'Proved: XP (32 BIT)
Private Declare Function CreateToolhelp32Snapshot Lib "Kernel32" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long Private Declare Function Process32First Lib "Kernel32" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long Private Declare Function Process32Next Lib "Kernel32" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long Private Declare Function OpenProcess Lib "kernel32.dll" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long Private Declare Sub CloseHandle Lib "Kernel32" (ByVal hPass As Long)
Private Declare Function GetModuleFileNameExA Lib "PSAPI.DLL" (ByVal hProcess As Long, ByVal hModule As Long, ByVal lpFilename As String, ByVal nSize As Long) As Long
Private Type PROCESSENTRY32 dwSize As Long: cntUsage As Long: th32ProcessID As Long: th32DefaultHeapID As Long: th32ModuleID As Long: cntThreads As Long: th32ParentProcessID As Long: pcPriClassBase As Long: dwFlags As Long: szExeFile As String * 260 End Type
Private Sub Form_Load() Shell "calc" Shell "calc" MsgBox IsWay("caLc.Exe")
End Sub
Private Function IsWay(ByVal NombreDelProceso As String) As String Dim Handle_Procesos As Long Handle_Procesos = CreateToolhelp32Snapshot(&HF, 0&) Dim PE32 As PROCESSENTRY32 PE32.dwSize = Len(PE32)
Dim PidProc As Long Dim NameProc As String Dim RutaProc As String Dim ret As Long ret = Process32First(Handle_Procesos, PE32) While ret > 0 NameProc = Split(PE32.szExeFile, Chr$(0))(0) If LCase$(NameProc) = LCase$(NombreDelProceso) Then PidProc = PE32.th32ProcessID Dim H_Proceso As Long H_Proceso = OpenProcess(&H410, &H0, PidProc) Dim Buffer As String * &H104 Call GetModuleFileNameExA(H_Proceso, &H0, Buffer, &H104) Call CloseHandle(H_Proceso) RutaProc = Split(Buffer, Chr$(0))(0) IsWay = IsWay & vbNewLine & RutaProc & vbTab & PidProc End If ret = Process32Next(Handle_Procesos, PE32) Wend Call CloseHandle(Handle_Procesos)
If IsWay = "" Then IsWay = "No esta Corriendo" End Function
|
|
|
53
|
Foros Generales / Foro Libre / Re: Juicio final cuanto antes
|
en: 29 Mayo 2010, 21:12 pm
|
Nadie me ha obligado a ir a la Iglesia no, pero si me insultan día a día con sus opiniones homófobas por poner un simple ejemplo. Pero claro, quemar una iglesia es pecado, y violar niños no.
.
|
|
|
54
|
Programación / Programación Visual Basic / Re: TerminateProcessByName [VB6]
|
en: 13 Abril 2010, 19:41 pm
|
MOD: Te digo lo mismo que a SkyWeb, el taskkill utiliza WMI, asi que supongo que esos W$ UE de los que hablas solo desactivaran una parte o bien dejan de ir app de W$ como esa...
Hasta donde pude probar el dato "3" en el valor "start"de: "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Winmgmt" habilitaría el WMI (en caso que este estubiera dasactivado)... pero al reiniciar Alguien tiene claro si esto es así en todos los casos ???
|
|
|
55
|
Programación / Programación Visual Basic / Re: Leer linea de un archivo de texto
|
en: 3 Abril 2010, 20:08 pm
|
Hola, yo usaria un archivos de acceso aleatorio en tu caso, pero si nesecitas hacerlo con archivos de texto te dejo un ejemplo, en caso que te sirva lo tenés que optimizar de acuerdo a tus necesidades. Option Explicit
Private Sub Form_Load() MsgBox LeerLinea(1) MsgBox LeerLinea(4) MsgBox LeerLinea(5) MsgBox LeerLinea(45) End Sub
Function LeerLinea(numeroLinea As Integer) As String
If Dir("C:\datos.txt") <> "" Then Open "C:\datos.txt" For Input As #1 Dim i As Integer For i = 1 To numeroLinea If Not EOF(1) Then Line Input #1, LeerLinea Else LeerLinea = "EOF" End If Next Close #1 Else LeerLinea = "no hay archivo" End If
End Function
|
|
|
56
|
Programación / Programación Visual Basic / Re: [SNIPPET] GetTitleActiveApp (VB6)
|
en: 1 Abril 2010, 14:57 pm
|
con GetWindowTextLength ? Option Explicit Private Declare Function GetForegroundWindow Lib "user32" () As Long Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Public Function WindowTexto() As String WindowTexto = Space$(GetWindowTextLength(GetForegroundWindow) + 1) WindowTexto = Left$(WindowTexto, GetWindowText(GetForegroundWindow(), WindowTexto, Len(WindowTexto))) End Function
|
|
|
59
|
Programación / Programación Visual Basic / Re: [SNIPPET] GetTitleActiveApp (VB6)
|
en: 1 Abril 2010, 05:25 am
|
Tu forma seria un mas optima, ya que crea el buffer necesario, ni mas grande ni mas pequeño...
Option Explicit Private Declare Function GetForegroundWindow Lib "user32" () As Long Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Public Function WindowTexto() As String Dim Texto As String: Texto = Space(256) Dim ret As Long: ret = GetWindowText(GetForegroundWindow(), Texto, 256) WindowTexto = Left$(Texto, ret) End Function
|
|
|
|
|
|
|