Cambiar la caption de una ventana poniendo yo los datos que quiero etc.
El cambia caption lo hice asi:
Citar
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetWindowText Lib "user32.dll" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
Private Sub Command1_Click()
Dim Ret As Long
Ret = FindWindow(vbNullString, Text1.Text)
SetWindowText Ret, Text2.Text
End Sub
Private Declare Function SetWindowText Lib "user32.dll" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
Private Sub Command1_Click()
Dim Ret As Long
Ret = FindWindow(vbNullString, Text1.Text)
SetWindowText Ret, Text2.Text
End Sub
(Generen el codigo en su vb para entender mejor)
Y me funciono bien, pero lo que quiero hacer ahora es mejorarlo, de manera que pueda ver los caption es un listbox y cambiandolo dandole click a la caption en la lista y poniendo en un textbox el nombre y dandole al commandbutton bueno, para que ejecute la acción de cambiar la caption.
Lo mas que pude acercarme a eso fue este codigo:
(generenlo en vb para entenderlo mejor)
Citar
Private Declare Function CreateToolhelpSnapshot Lib "kernel32" Alias "CreateToolhelp32Snapshot" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long
Private Declare Function ProcessFirst Lib "kernel32" Alias "Process32First" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Function ProcessNext Lib "kernel32" Alias "Process32Next" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Sub CloseHandle Lib "kernel32" (ByVal hPass 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
'Para llenar el listbox con los procesos
Sub RellenaLista()
On Error Resume Next
Dim hSnapShot As Long
Dim uProceso As PROCESSENTRY32
Dim res As Long
List1.Clear
hSnapShot = CreateToolhelpSnapshot(2&, 0&)
If hSnapShot <> 0 Then
uProceso.dwSize = Len(uProceso)
res = ProcessFirst(hSnapShot, uProceso)
Do While res
List1.AddItem Left$(uProceso.szExeFile, InStr(uProceso.szExeFile, Chr$(0)) - 1)
List1.ItemData(List1.NewIndex) = uProceso.th32ProcessID
res = ProcessNext(hSnapShot, uProceso)
Loop
Call CloseHandle(hSnapShot)
End If
End Sub
Private Sub Form_Load()
RellenaLista
End Sub
Private Declare Function ProcessFirst Lib "kernel32" Alias "Process32First" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Function ProcessNext Lib "kernel32" Alias "Process32Next" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Sub CloseHandle Lib "kernel32" (ByVal hPass 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
'Para llenar el listbox con los procesos
Sub RellenaLista()
On Error Resume Next
Dim hSnapShot As Long
Dim uProceso As PROCESSENTRY32
Dim res As Long
List1.Clear
hSnapShot = CreateToolhelpSnapshot(2&, 0&)
If hSnapShot <> 0 Then
uProceso.dwSize = Len(uProceso)
res = ProcessFirst(hSnapShot, uProceso)
Do While res
List1.AddItem Left$(uProceso.szExeFile, InStr(uProceso.szExeFile, Chr$(0)) - 1)
List1.ItemData(List1.NewIndex) = uProceso.th32ProcessID
res = ProcessNext(hSnapShot, uProceso)
Loop
Call CloseHandle(hSnapShot)
End If
End Sub
Private Sub Form_Load()
RellenaLista
End Sub
Pero me muestra los procesos, no las caption de los .exe abiertos. Y ahi me quede.
Espero que ustedes me puedan ayudar a terminar el proyecto, por que me quede estancado.
Saludos!