elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Como proteger una cartera - billetera de Bitcoin


  Mostrar Temas
Páginas: 1 ... 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 [72] 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 ... 105
711  Programación / .NET (C#, VB.NET, ASP) / [SOURCE] RegEx .NET en: 2 Mayo 2013, 10:23 am



DESCRIPCIÓN:

RegEx.NET es una aplicación sencilla para crear y testear expresiones regulares.

Es de diseño minimalista al estilo del editor de texto "Sublime Text", aunque en esta nueva versión le he añadido un selector de tema para los que prefieres las cosas blancas.

· Permite separar los resultados por grupos (sub-expresiones).
· Copiar los resultados encontrados por el regex al portapapeles.
· Cargar o arrastrar un archivo de texto diréctamente.
· Elegir entre una pequeña cantidad de expresiones regulares predefinidas.
· Comprueba si el RegEx tiene la sintaxis válida para .NET.

NOTAS: Aún falta por mejorar la precisión de detección (mejor dicho, el cambio de los colores) cuando el texto del richtextbox se modifica manualmente.



IMÁGENES:



   





DEMOSTRACIÓN:

VERSIÓN NUEVA:


VERSIÓN ANTIGUA:




DESCARGA:
http://elektrostudios.tk/RegEx.NET.zip

Incluye source, compilado, e instalador.
712  Programación / Scripting / MOVIDO: codigo llave para los control admin en: 1 Mayo 2013, 11:06 am
El tema ha sido movido a Nivel Web.

http://foro.elhacker.net/index.php?topic=389232.0
713  Programación / Scripting / MOVIDO: codigo universal para los panel control en: 1 Mayo 2013, 11:05 am
El tema ha sido movido a Nivel Web.

http://foro.elhacker.net/index.php?topic=389235.0
714  Programación / .NET (C#, VB.NET, ASP) / [SOURCE] AeroSwitch en: 30 Abril 2013, 13:56 pm
Una aplicación para alternar entre el modo Aero y cambiar de tema sencíllamente.

   

Se adjunta al áera de notificación de la barra de taréas (El systray):



Y también se puede ejecutar por consola:



Demostración:


Source:
http://elektrostudios.tk/AeroSwitch.zip
Incluye código fuente, versión portable, y versión instalable. Lo de siempre.
715  Programación / Programación General / [SOLUCIONADO] Como localizar un nuevo certificado usando CertUtil? en: 22 Abril 2013, 01:10 am
Tengo esta duda:

Si creo un nuevo certificado con la utilidad makecert de las SDK de Microsoft:
Código:
makecert -r -pe -a sha1 -n "CN=ElektroSoft" -b 01/01/2013 -e 01/01/2050 -ss my -$ individual 

Se supone que ese comando nos almacena el certificado en "my",

Entonces con la utilidad Certutil, si intento listar los certificados de "my" para obtener el número de serie, sólo me sale una entrada:

Código
  1. C:\Users\Administrador\Desktop\Nueva carpeta>CERTUTIL -store my
  2. my
  3. ================ Certificado 0 ================
  4. Número de serie: 586a7358ebdce8854def26875f0f38ab
  5. Emisor: CN=localhost
  6. NotBefore: 22/02/2013 4:43
  7. NotAfter: 22/02/2018 2:00
  8. Sujeto: CN=localhost
  9. La firma coincide con la clave pública
  10. Certificado raíz: el sujeto coincide con el emisor
  11. Plantilla:
  12. Hash de cert(sha1): 1b 92 19 ef 19 ce d1 09 ad 87 13 73 56 0c cf 0a 57 29 cf 81
  13.  Contenedor de claves = IIS Express Development Certificate Container
  14.  Nombre de contenedor exclusivo: fad662b360941f26a1193357aab3c12d_a61f2a11-eaf9
  15. -4c14-9a63-d3613bf3bd2c
  16.  Proveedor = Microsoft RSA SChannel Cryptographic Provider
  17. Prueba de cifrado correcta
  18. CertUtil: -store comando completado correctamente.
  19.  

Entonces, si el certificado que he creado no está en "my", ¿¡donde está mi certificado!?

He probado a usar -repairstore y en fín todos los parámetros de cerutil que he visto.

Esto quiero conseguirlo para automatizar la taréa en un Bat, en un PC que no es de mi propiedad para permitirle generar un certificado con la clave pública y privada, desde la consola.

Sólamente con encontrar la ubicación del certificado (para poder obtener el número de serie) me sería suficiente.

PD: si uso la herramienta certmgr.msc puedo ver el certificado en la carpeta "\Personal\Certificados", pero no sé como encontrarla desde la CMD.

Gracias por leer!
716  Programación / .NET (C#, VB.NET, ASP) / Pasar el nombre de una subrutina como argumento de una función? en: 18 Abril 2013, 15:21 pm
Hola

Estoy intentando crear una función genérica para crear Threads.

El problema es que no consigo pasarle a la función el nombre de un Sub como argumento, para poder asignarlo como el Sub del nuevo thread que se va a crear,
sólamente he llegado a conseguir pasarle el nombre de una función, lo cual no me sirve para nada, porque según me dice la IDE el procedimiento de un thread debe ser un Sub, no una función.

¿Tienen idea de como puedo conseguir resolverlo?

Me gustaría poder pasarle el nombre del Sub a la función sin tener que declarar un delegado fuera de la función, porque mi intención es hacer una función genérica que acepte cualquier nombre de un Sub como argumento, para simplificar las cosas.

El code:
Código
  1.    Public Class Form1
  2.  
  3.    ' Desired usage:
  4.    ' Make_Thread(Thread Variable, Thread Name, Thread Priority, Thread Sub)
  5.    '
  6.    ' Example:
  7.    ' Make_Thread(Thread_1, "Low thread", Threading.ThreadPriority.Low, AddressOf Test_Sub)
  8.  
  9.    Private Thread_1 As Threading.Thread ' Thread Variable
  10.  
  11.    Private Function Make_Thread(Of TKey)(ByRef Thread_Variable As Threading.Thread, _
  12.                           ByVal Thread_Name As String, _
  13.                           ByVal Thread_Priority As Threading.ThreadPriority, _
  14.                           ByRef Thread_Sub As Func(Of String, TKey)) As Boolean ' I'd ByRef a function but really I will pass a Subroutine.
  15.  
  16.        ' See if the thread is already running.
  17.        Dim is_running As Boolean
  18.        If Thread_Variable Is Nothing Then _
  19.             is_running = False _
  20.        Else is_running = Thread_Variable.IsAlive
  21.  
  22.        ' If the thread is already running, do nothing.
  23.        If is_running Then Return False : Exit Function
  24.  
  25.        ' Make the thread.
  26.        Thread_Variable = New Threading.Thread(AddressOf Thread_Sub)
  27.        Thread_Variable.Priority = Thread_Priority
  28.        Thread_Variable.IsBackground = True
  29.        Thread_Variable.Name = Thread_Name
  30.  
  31.        ' Start the thread.
  32.        Thread_Variable.Start()
  33.        Return True
  34.  
  35.    End Function
  36.  
  37.    Private Sub Test_Sub()
  38.        MsgBox("A message from the thread!")
  39.    End Sub
  40.  
  41.    End Class
  42.  
717  Programación / Scripting / MOVIDO: Robot publicitario en pascal R-WEB [Aporte], (Aumenta tus visitas!) en: 17 Abril 2013, 18:29 pm
El tema ha sido movido a Programación General.
Delphi/Pascal no es un lenguaje interpretado :P.
http://foro.elhacker.net/index.php?topic=388274.0
718  Programación / Scripting / [APORTE] [Inno Setup] Plantilla para usarla como script por defecto. en: 17 Abril 2013, 13:21 pm
A petición de un usuario aquí tienen la plantilla por defecto que uso para mis instaladores...


Setup.iss

Código
  1. ; = = = = = = = = = = = = = = = = = = =
  2. ; Default Template (by Elektro H@cker) |
  3. ;                                      |
  4. ;            InnoSetup 5.5.3           |
  5. ; = = = = = = = = = = = = = = = = = = =
  6.  
  7. [Setup]
  8.  
  9. ; Info
  10. ; ----
  11. #define Name "Application"
  12. #define Version "1.0"
  13. #define EXE "Application.exe"
  14. AppName={#Name}
  15. AppVersion={#Version}
  16. AppVerName={#Name} {#Version}
  17. AppCopyright=Elektro H@cker
  18. AppPublisher=Elektro H@cker
  19.  
  20. ; Paths
  21. ; -----
  22. DefaultDirName={pf}\{#Name}
  23. DefaultGroupName={#Name}
  24. OutputDir=.\Output\
  25. OutputBaseFilename={#Name}
  26. UninstallDisplayIcon={app}\{#EXE}
  27.  
  28. ; Resources
  29. ; ---------
  30. ;SetupIconFile=Icon.ico
  31. ;WizardImageFile=Icon.bmp
  32. ;WizardSmallImageFile=Icon.bmp
  33. ;InfoBeforeFile=Info.txt
  34.  
  35. ; Compression
  36. ; -----------
  37. Compression=lzma/ultra
  38. InternalCompressLevel=Ultra
  39. SolidCompression=True
  40.  
  41. ; Appearance
  42. ; ----------
  43. AlwaysShowComponentsList=False
  44. DisableDirPage=True
  45. DisableProgramGroupPage=True
  46. DisableReadyPage=True
  47. DisableStartupPrompt=True
  48. FlatComponentsList=False
  49. LanguageDetectionMethod=None
  50. PrivilegesRequired=PowerUser
  51. RestartIfNeededByRun=False
  52. ShowLanguageDialog=NO
  53. ShowTasksTreeLines=True
  54. Uninstallable=True
  55. ArchitecturesAllowed=x86 x64
  56. ;ArchitecturesInstallIn64BitMode=x64
  57.  
  58. [Languages]
  59. Name: spanish; MessagesFile: compiler:Languages\Spanish.isl
  60.  
  61. [Dirs]
  62. ;{sd}                  = C:\
  63. ;{commonappdata}       = C:\ProgramData
  64. ;{sd}\Users\{username} = C:\Users\UserName
  65. ;{userdesktop}         = C:\Users\UserName\Desktop
  66. ;{localappdata}        = C:\Users\UserName\AppData\Local
  67. ;{userappdata}         = C:\Users\UserName\AppData\Roaming
  68. ;{userstartmenu}       = C:\Users\UserName\AppData\Roaming\Microsoft\Windows\Start Menu
  69.  
  70. [Files]
  71. ;Source: {app}\*.*; DestDir: {app}; DestName:; Attribs:; Flags:;
  72. ;Attribs: ReadOnly Hidden System
  73. ;DestName: Example.exe
  74. ;Flags: 32bit 64bit Deleteafterinstall IgnoreVersion NoCompression Onlyifdoesntexist recursesubdirs uninsneveruninstall
  75.  
  76. [Registry]
  77. ;Root: HKCR; Subkey: SystemFileAssociations\.ext\Shell\OPTION; ValueName: Icon; ValueType: String; ValueData: {app}\{#Exe}; Flags: ;
  78. ;Root: HKCR; Subkey: SystemFileAssociations\.ext\Shell\OPTION\Command; ValueType: String; ValueData: """{app}\{#Exe}"" ""%1"""; Flags: ;
  79. ;Flags: uninsdeletevalue uninsdeletekey
  80.  
  81. [Tasks]
  82. ;Name: Identifier; Description: Title; GroupDescription: Group; Flags:;
  83. ;Flags: Unchecked
  84.  
  85. [Run]
  86. ;Filename: "{cmd}"; Parameters: "/C command"; StatusMsg: "Installing..."; Flags: RunHidden WaitUntilTerminated
  87. ;Filename: {app}\{#Exe}; Description: {cm:LaunchProgram,{#Nombre}}; Flags: NoWait PostInstall SkipIfSilent ShellExec Unchecked
  88. ;Flags: 32bit 64bit RunHidden WaitUntilTerminated NoWait PostInstall SkipIfSilent ShellExec Unchecked
  89.  
  90. [Icons]
  91. Name: {userstartmenu}\Programs\{#Name}; Filename: {app}\{#Exe}; Iconfilename: {app}\{#Exe}; WorkingDir: {app}
  92.  
  93. [Code]
  94.  
  95. const
  96.  Custom_Height = 440;
  97.  Custom_ProgressBar_Height = 20;
  98.  Page_Color = clwhite;
  99.  Page_Color_Alternative1 = clblack;
  100.  Page_Color_Alternative2 = clwhite;
  101.  Font_Color = clblack;
  102.  
  103.  
  104. var
  105.  DefaultTop,
  106.  DefaultLeft,
  107.  DefaultHeight,
  108.  DefaultBackTop,
  109.  DefaultNextTop,
  110.  DefaultCancelTop,
  111.  DefaultBevelTop,
  112.  DefaultOuterHeight: Integer;
  113.  
  114.  
  115. procedure InitializeWizard();
  116. begin
  117.  
  118.  DefaultTop := WizardForm.Top;
  119.  DefaultLeft := WizardForm.Left;
  120.  DefaultHeight := WizardForm.Height;
  121.  DefaultBackTop := WizardForm.BackButton.Top;
  122.  DefaultNextTop := WizardForm.NextButton.Top;
  123.  DefaultCancelTop := WizardForm.CancelButton.Top;
  124.  DefaultBevelTop := WizardForm.Bevel.Top;
  125.  DefaultOuterHeight := WizardForm.OuterNotebook.Height;
  126.  
  127.  
  128.  // Pages (Size)
  129.  WizardForm.Height := Custom_Height;
  130.  WizardForm.InnerPage.Height := WizardForm.InnerPage.Height + (Custom_Height - DefaultHeight);
  131.  WizardForm.LicensePage.Height := WizardForm.LicensePage.Height + (Custom_Height - DefaultHeight);
  132.  
  133.  
  134.  // Pages (Color)
  135.  WizardForm.color := Page_Color_Alternative1;
  136.  WizardForm.FinishedPage.Color  := Page_Color;
  137.  WizardForm.InfoAfterPage.Color := Page_Color;
  138.  WizardForm.InfoBeforePage.Color := Page_Color;
  139.  WizardForm.InnerPage.Color := Page_Color;
  140.  WizardForm.InstallingPage.color := Page_Color;
  141.  WizardForm.LicensePage.Color := Page_Color;
  142.  WizardForm.PasswordPage.color := Page_Color;
  143.  WizardForm.PreparingPage.color := Page_Color;
  144.  WizardForm.ReadyPage.Color := Page_Color;
  145.  WizardForm.SelectComponentsPage.Color  := Page_Color;
  146.  WizardForm.SelectDirPage.Color  := Page_Color;
  147.  WizardForm.SelectProgramGroupPage.color := Page_Color;
  148.  WizardForm.SelectTasksPage.color := Page_Color;
  149.  WizardForm.UserInfoPage.color := Page_Color;
  150.  WizardForm.WelcomePage.color := Page_Color;
  151.  
  152.  
  153.  // Controls (Size)
  154.  WizardForm.InfoAfterMemo.Height := (Custom_Height - (DefaultHeight / 2));
  155.  WizardForm.InfoBeforeMemo.Height := (Custom_Height - (DefaultHeight / 2));
  156.  WizardForm.InnerNotebook.Height :=  WizardForm.InnerNotebook.Height + (Custom_Height - DefaultHeight);
  157.  WizardForm.LicenseMemo.Height := WizardForm.LicenseMemo.Height + (Custom_Height - DefaultHeight);
  158.  WizardForm.OuterNotebook.Height := WizardForm.OuterNotebook.Height + (Custom_Height - DefaultHeight);
  159.  WizardForm.ProgressGauge.Height := Custom_ProgressBar_Height
  160.  WizardForm.ReadyMemo.Height := (Custom_Height - (DefaultHeight / 2));
  161.  WizardForm.Taskslist.Height := (Custom_Height - (DefaultHeight / 2));
  162.  WizardForm.WizardBitmapImage.Height := (Custom_Height - (DefaultHeight - DefaultBevelTop));
  163.  WizardForm.WizardBitmapImage2.Height  := (Custom_Height - (DefaultHeight - DefaultBevelTop));
  164.  
  165.  
  166.  // Controls (Location)
  167.  WizardForm.BackButton.Top := DefaultBackTop + (Custom_Height - DefaultHeight);
  168.  WizardForm.Bevel.Top := DefaultBevelTop + (Custom_Height - DefaultHeight);
  169.  WizardForm.CancelButton.Top := DefaultCancelTop + (Custom_Height - DefaultHeight);
  170.  WizardForm.LicenseAcceptedRadio.Top := WizardForm.LicenseAcceptedRadio.Top + (Custom_Height - DefaultHeight);
  171.  WizardForm.LicenseNotAcceptedRadio.Top := WizardForm.LicenseNotAcceptedRadio.Top + (Custom_Height - DefaultHeight);
  172.  WizardForm.NextButton.Top := DefaultNextTop + (Custom_Height - DefaultHeight);
  173.  WizardForm.Top := DefaultTop - (Custom_Height - DefaultHeight) div 2;
  174.  //WizardForm.ProgressGauge.Top := (DefaultHeight / 2)
  175.  
  176.  
  177.  // Controls (Back Color)
  178.  WizardForm.DirEdit.Color  := Page_Color_Alternative2;
  179.  WizardForm.GroupEdit.Color  := Page_Color_Alternative2;
  180.  WizardForm.InfoAfterMemo.Color := Page_Color_Alternative2;
  181.  WizardForm.InfoBeforeMemo.Color := Page_Color_Alternative2;
  182.  WizardForm.LicenseMemo.Color := Page_Color_Alternative2;
  183.  WizardForm.MainPanel.Color := Page_Color;
  184.  WizardForm.PasswordEdit.Color  := Page_Color_Alternative2;
  185.  WizardForm.ReadyMemo.Color := Page_Color_Alternative2;
  186.  WizardForm.Taskslist.Color := Page_Color;
  187.  WizardForm.UserInfoNameEdit.Color  := Page_Color_Alternative2;
  188.  WizardForm.UserInfoOrgEdit.Color  := Page_Color_Alternative2;
  189.  WizardForm.UserInfoSerialEdit.Color  := Page_Color_Alternative2;
  190.  
  191.  
  192.  // Controls (Font Color)
  193.  WizardForm.FinishedHeadingLabel.font.color  := Font_Color;
  194.  WizardForm.InfoafterMemo.font.Color  := Font_Color;
  195.  WizardForm.FinishedLabel.font.color  := Font_Color;
  196.  WizardForm.DirEdit.font.Color  := Page_Color_Alternative1;
  197.  WizardForm.Font.color := Font_Color;
  198.  WizardForm.GroupEdit.font.Color  := Page_Color_Alternative1;
  199.  WizardForm.InfoBeforeMemo.font.Color  := Page_Color_Alternative1;
  200.  WizardForm.LicenseMemo.font.Color  := Page_Color_Alternative1;
  201.  WizardForm.MainPanel.font.Color := Font_Color;
  202.  WizardForm.PageDescriptionLabel.font.color  := Font_Color;
  203.  WizardForm.PageNameLabel.font.color  := Font_Color;
  204.  WizardForm.PasswordEdit.font.Color  := Page_Color_Alternative1;
  205.  WizardForm.Taskslist.font.Color  := Font_Color;
  206.  WizardForm.UserInfoNameEdit.font.Color  := Page_Color_Alternative1;
  207.  WizardForm.UserInfoOrgEdit.font.Color  := Page_Color_Alternative1;
  208.  WizardForm.UserInfoSerialEdit.font.Color  := Page_Color_Alternative1;
  209.  WizardForm.WelcomeLabel1.font.color  := Font_Color;
  210.  WizardForm.WelcomeLabel2.font.color  := Font_Color;
  211.  WizardForm.ReadyMemo.font.Color := Page_Color_Alternative1;
  212.  
  213. end;


Este es el aspecto por defecto:




Y se puede customizar un poco el aspecto para conseguir algo parecido a esto, sólamente cambiando las variables de la plantilla...

[/code]
719  Programación / .NET (C#, VB.NET, ASP) / [APORTE] Plantillas de Game Launchers para juegos de Steam en: 10 Abril 2013, 16:21 pm
Estos dos proyectos los comparto como plantillas para las personas que quieren hacer un Game launcher.

Los dos poryectos son idénticos, y estas son algunas de sus características a resaltar:

· Configuración portable en un archivo INI sencillísima e intuitiva (Para usarlo en juegos autoextraibles con WinRAR por ejemplo)
· Drag&drop en los textboxes
· Permite soltar accesos directos también (.lnk) en los textboxes,
· La mayor parte del code (sobre todo los eventos de controles) está muy simplificado y optimizado
· Está todo bastante optimizado en el code para poder modificar el diseño fácilmente mediante variables (título del juego y del launcher, colores y fuente de texto, etc...)
· Varios controles de errores

...Y en definitiva creo que me han quedado bonito como plantillas.

Los dos proyectos son WinForms, y he usado VS2012 y el FrameWork 3.5.





El método y el orden de carga del programa es este:

1. Primero se ejecuta Steam (si estuviera seleccionado) con el parámetro "-applaunch 0" para que no salga la ventana de auto-login. (el proceso espera a que Steam se haya cargado complétamente)
2. Se ejecuta el Trainer (si hubiera alguno seleccionado)
3. Se ejecuta la aplicación alternativa (si hubiera alguna seleccionada), esta aplicación alternativa puede ser por ejemplo un programa para bloquear el mouse... http://foro.elhacker.net/net/source_mouselock_gui_version-t387309.0.html
4. Se ejecuta el Juego y se monitoriza su ejecución hasta que el proceso del juego se cierre.

Descarga: www.elektrostudios.tk/Game Launchers by Elektro H@cker.rar

Espero que os guste,
Saludos!
720  Programación / .NET (C#, VB.NET, ASP) / Sobre los child handles en: 9 Abril 2013, 19:54 pm
Necesito listar todos los handles hijos de un proceso, para eso utilizo esta Class: http://kellyschronicles.wordpress.com/2008/06/23/get-window-handles-associated-with-process-in-vb-net/

Código
  1. Imports System.Collections.Generic
  2. Imports System.Runtime.InteropServices
  3. Imports System.Text
  4.  
  5. Public Class ApiWindow
  6.    Public MainWindowTitle As String = ""
  7.    Public ClassName As String = ""
  8.    Public hWnd As Int32
  9. End Class
  10.  
  11. ''' <summary>
  12. ''' Enumerate top-level and child windows
  13. ''' </summary>
  14. ''' <example>
  15. ''' Dim enumerator As New WindowsEnumerator()
  16. ''' For Each top As ApiWindow in enumerator.GetTopLevelWindows()
  17. '''    Console.WriteLine(top.MainWindowTitle)
  18. '''    For Each child As ApiWindow child in enumerator.GetChildWindows(top.hWnd)
  19. '''        Console.WriteLine(" " + child.MainWindowTitle)
  20. '''    Next child
  21. ''' Next top
  22. ''' </example>
  23. Public Class WindowsEnumerator
  24.  
  25.    Private Delegate Function EnumCallBackDelegate(ByVal hwnd As Integer, ByVal lParam As Integer) As Integer
  26.  
  27.    ' Top-level windows.
  28.    Private Declare Function EnumWindows Lib "user32" _
  29.     (ByVal lpEnumFunc As EnumCallBackDelegate, ByVal lParam As Integer) As Integer
  30.  
  31.    ' Child windows.
  32.    Private Declare Function EnumChildWindows Lib "user32" _
  33.     (ByVal hWndParent As Integer, ByVal lpEnumFunc As EnumCallBackDelegate, ByVal lParam As Integer) As Integer
  34.  
  35.    ' Get the window class.
  36.    Private Declare Function GetClassName _
  37.     Lib "user32" Alias "GetClassNameA" _
  38.     (ByVal hwnd As Integer, ByVal lpClassName As StringBuilder, ByVal nMaxCount As Integer) As Integer
  39.  
  40.    ' Test if the window is visible--only get visible ones.
  41.    Private Declare Function IsWindowVisible Lib "user32" _
  42.     (ByVal hwnd As Integer) As Integer
  43.  
  44.    ' Test if the window's parent--only get the one's without parents.
  45.    Private Declare Function GetParent Lib "user32" _
  46.     (ByVal hwnd As Integer) As Integer
  47.  
  48.    ' Get window text length signature.
  49.    Private Declare Function SendMessage _
  50.     Lib "user32" Alias "SendMessageA" _
  51.     (ByVal hwnd As Int32, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Int32
  52.  
  53.    ' Get window text signature.
  54.    Private Declare Function SendMessage _
  55.     Lib "user32" Alias "SendMessageA" _
  56.     (ByVal hwnd As Int32, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal lParam As StringBuilder) As Int32
  57.  
  58.    Private _listChildren As New List(Of ApiWindow)
  59.    Private _listTopLevel As New List(Of ApiWindow)
  60.  
  61.    Private _topLevelClass As String = ""
  62.    Private _childClass As String = ""
  63.  
  64.    ''' <summary>
  65.    ''' Get all top-level window information
  66.    ''' </summary>
  67.    ''' <returns>List of window information objects</returns>
  68.    Public Overloads Function GetTopLevelWindows() As List(Of ApiWindow)
  69.  
  70.        EnumWindows(AddressOf EnumWindowProc, &H0)
  71.  
  72.        Return _listTopLevel
  73.  
  74.    End Function
  75.  
  76.    Public Overloads Function GetTopLevelWindows(ByVal className As String) As List(Of ApiWindow)
  77.  
  78.        _topLevelClass = className
  79.  
  80.        Return Me.GetTopLevelWindows()
  81.  
  82.    End Function
  83.  
  84.    ''' <summary>
  85.    ''' Get all child windows for the specific windows handle (hwnd).
  86.    ''' </summary>
  87.    ''' <returns>List of child windows for parent window</returns>
  88.    Public Overloads Function GetChildWindows(ByVal hwnd As Int32) As List(Of ApiWindow)
  89.  
  90.        ' Clear the window list.
  91.        _listChildren = New List(Of ApiWindow)
  92.  
  93.        ' Start the enumeration process.
  94.        EnumChildWindows(hwnd, AddressOf EnumChildWindowProc, &H0)
  95.  
  96.        ' Return the children list when the process is completed.
  97.        Return _listChildren
  98.  
  99.    End Function
  100.  
  101.    Public Overloads Function GetChildWindows(ByVal hwnd As Int32, ByVal childClass As String) As List(Of ApiWindow)
  102.  
  103.        ' Set the search
  104.        _childClass = childClass
  105.  
  106.        Return Me.GetChildWindows(hwnd)
  107.  
  108.    End Function
  109.  
  110.    ''' <summary>
  111.    ''' Callback function that does the work of enumerating top-level windows.
  112.    ''' </summary>
  113.    ''' <param name="hwnd">Discovered Window handle</param>
  114.    ''' <returns>1=keep going, 0=stop</returns>
  115.    Private Function EnumWindowProc(ByVal hwnd As Int32, ByVal lParam As Int32) As Int32
  116.  
  117.        ' Eliminate windows that are not top-level.
  118.        If GetParent(hwnd) = 0 AndAlso CBool(IsWindowVisible(hwnd)) Then
  119.  
  120.            ' Get the window title / class name.
  121.            Dim window As ApiWindow = GetWindowIdentification(hwnd)
  122.  
  123.            ' Match the class name if searching for a specific window class.
  124.            If _topLevelClass.Length = 0 OrElse window.ClassName.ToLower() = _topLevelClass.ToLower() Then
  125.                _listTopLevel.Add(window)
  126.            End If
  127.  
  128.        End If
  129.  
  130.        ' To continue enumeration, return True (1), and to stop enumeration
  131.        ' return False (0).
  132.        ' When 1 is returned, enumeration continues until there are no
  133.        ' more windows left.
  134.  
  135.        Return 1
  136.  
  137.    End Function
  138.  
  139.    ''' <summary>
  140.    ''' Callback function that does the work of enumerating child windows.
  141.    ''' </summary>
  142.    ''' <param name="hwnd">Discovered Window handle</param>
  143.    ''' <returns>1=keep going, 0=stop</returns>
  144.    Private Function EnumChildWindowProc(ByVal hwnd As Int32, ByVal lParam As Int32) As Int32
  145.  
  146.        Dim window As ApiWindow = GetWindowIdentification(hwnd)
  147.  
  148.        ' Attempt to match the child class, if one was specified, otherwise
  149.        ' enumerate all the child windows.
  150.        If _childClass.Length = 0 OrElse window.ClassName.ToLower() = _childClass.ToLower() Then
  151.            _listChildren.Add(window)
  152.        End If
  153.  
  154.        Return 1
  155.  
  156.    End Function
  157.  
  158.    ''' <summary>
  159.    ''' Build the ApiWindow object to hold information about the Window object.
  160.    ''' </summary>
  161.    Private Function GetWindowIdentification(ByVal hwnd As Integer) As ApiWindow
  162.  
  163.        Const WM_GETTEXT As Int32 = &HD
  164.        Const WM_GETTEXTLENGTH As Int32 = &HE
  165.  
  166.        Dim window As New ApiWindow()
  167.  
  168.        Dim title As New StringBuilder()
  169.  
  170.        ' Get the size of the string required to hold the window title.
  171.        Dim size As Int32 = SendMessage(hwnd, WM_GETTEXTLENGTH, 0, 0)
  172.  
  173.        ' If the return is 0, there is no title.
  174.        If size > 0 Then
  175.            title = New StringBuilder(size + 1)
  176.  
  177.            SendMessage(hwnd, WM_GETTEXT, title.Capacity, title)
  178.        End If
  179.  
  180.        ' Get the class name for the window.
  181.        Dim classBuilder As New StringBuilder(64)
  182.        GetClassName(hwnd, classBuilder, 64)
  183.  
  184.        ' Set the properties for the ApiWindow object.
  185.        window.ClassName = classBuilder.ToString()
  186.        window.MainWindowTitle = title.ToString()
  187.        window.hWnd = hwnd
  188.  
  189.        Return window
  190.  
  191.    End Function
  192.  
  193. End Class


Y la uso de esta manera, pero solo obtengo el "main" handle:

Código
  1. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  2.    Dim enumerator As New WindowsEnumerator()
  3.    For Each top As ApiWindow In enumerator.GetTopLevelWindows()
  4.        If top.MainWindowTitle.ToLower.Contains("firefox") Then
  5.            RichTextBox1.Text += vbNewLine & ("main handle: " & top.MainWindowTitle)
  6.            For Each child As ApiWindow In enumerator.GetChildWindows(top.hWnd)
  7.                RichTextBox1.Text += vbNewLine & ("child handle: " & " " + child.MainWindowTitle)
  8.            Next
  9.        End If
  10.    Next top
  11.  
  12. End Sub

Así que algo está mal.

Lo que quiero es obtener todos los handles de un proceso, como por ejemplo el output que nos da la utilidad CommandLine "CMDOW" con este comando:

Código:
C:\>cmdow | find /i "firefox"

Código:
0x2C0242 1  912 Res Ina Ena Hid firefox  Code Sample <pre><code> Ctrl+K
0x1F0C10 1  912 Res Ina Ena Hid firefox  pinvoke.net: EnumWindowsProc (Delegate
0x6E06A8 1  912 Res Ina Ena Hid firefox  MozillaDropShadowWindowClass
0x310ADA 1  912 Res Ina Ena Hid firefox  MozillaDropShadowWindowClass
0x610D3A 1  912 Res Ina Ena Hid firefox  MozillaWindowClass
0x840A54 1  912 Res Ina Ena Hid firefox  MozillaDropShadowWindowClass
0x9A08D6 1  912 Res Ina Ena Hid firefox  Search using Google (English)
0x17E057C 1  912 Res Ina Ena Hid firefox  MozillaDropShadowWindowClass
0x2E0A5A 1  912 Res Ina Ena Hid firefox  MozillaWindowClass
0x4A04DC 1  912 Min Ina Ena Vis firefox  Get all child handles of process - Sta
0xA40994 1  912 Min Ina Ena Hid firefox  pinvoke.net: EnumWindowsProc (Delegate
0x110CF4 1  912 Min Ina Ena Hid firefox  pinvoke.net: EnumChildWindows (user32)
0x560270 1  912 Min Ina Ena Hid firefox  Get handles of process forms c# - Stac
0x7B0CCC 1  912 Min Ina Ena Hid firefox  Get child window handles in C# - Stack
0x74040A 1  912 Min Ina Ena Hid firefox  Get all child handles of process - Sta
0xC0028A 1  912 Min Ina Ena Hid firefox  Get Window Handles Associated With Pro
0xAC067C 1  912 Min Ina Ena Hid firefox  vbnet get child handles of process - B
0x6308B0 1  912 Min Ina Ena Hid firefox  Process Class (System.Diagnostics) - M
0xB20B2E 1  912 Min Ina Ena Hid firefox  How to wait the process until the proc
0xA7021C 1  912 Min Ina Ena Hid firefox  vb.net - Waiting For Process To Comple
0xD30356 1  912 Min Ina Ena Hid firefox  FreeVBCode code snippet: Execute a Pro
0x583207D0 1  912 Res Ina Ena Hid firefox  nsAppShell:EventWindow
0x3C0550 1  912 Res Ina Ena Hid firefox  DDEMLEvent
0x3E065C 1  912 Res Ina Ena Hid firefox  DDEMLMom
0x590288 1  912 Res Ina Ena Hid firefox  FirefoxMessageWindow
0x2D085A 1  912 Min Ina Ena Hid firefox  vbnet wait for process end - Buscar co
0x5F0584 1  912 Res Ina Ena Hid firefox  MCI command handling window
0x2307D2 1  912 Res Ina Ena Hid firefox  MozillaHiddenWindowClass
0x1760466 1  912 Res Ina Dis Hid firefox  MSCTFIME UI
0x200CB4 1  912 Res Ina Dis Hid firefox  Default IME
0x510320 1  912 Res Ina Dis Hid firefox  Default IME
Páginas: 1 ... 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 [72] 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 ... 105
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines