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

 

 


Tema destacado: Recopilación Tutoriales y Manuales Hacking, Seguridad, Privacidad, Hardware, etc


  Mostrar Mensajes
Páginas: 1 ... 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 [926] 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 ... 1236
9251  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!
9252  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 10 Abril 2013, 13:25 pm
· Cargar fuentes de texto desde los recursos:

Nota: Este code ya lo posteé pero se me olvidó agregar lo más importante, la class, así que lo vuelvo a postear xD

Código
  1. #Region " Use Custom Text-Font "
  2.  
  3.    ' [ Use Custom Text-Font ]
  4.    '
  5.    ' Instructions :
  6.    ' 1. Add a .TTF font to the resources
  7.    ' 2. Add the class
  8.    ' 3. Use it
  9.    '
  10.    ' Examples:
  11.    ' Label1.Font = New Font(GameFont.Font, 10.0!)
  12.    ' Label1.Text = "This is your custom font !!"
  13.  
  14.    Dim MyFont As New CustomFont(My.Resources.kakakaka)
  15.  
  16.    Private Sub Main_Disposed(sender As Object, e As System.EventArgs) Handles Me.Disposed
  17.        MyFont.Dispose()
  18.    End Sub
  19.  
  20.    ' CustomFont.vb
  21. #Region " CustomFont Class "
  22.  
  23. Imports System.Drawing
  24. Imports System.Drawing.Text
  25. Imports System.Runtime.InteropServices
  26.  
  27.    ''' <summary>
  28.    ''' Represents a custom font not installed on the user's system.
  29.    ''' </summary>
  30.    Public NotInheritable Class CustomFont
  31.        Implements IDisposable
  32.  
  33.        Private fontCollection As New PrivateFontCollection()
  34.        Private fontPtr As IntPtr
  35.  
  36. #Region "Constructor"
  37.        ''' <summary>
  38.        ''' Creates a new custom font using the specified font data.
  39.        ''' </summary>
  40.        ''' <param name="fontData">The font data representing the font.</param>
  41.        Public Sub New(ByVal fontData() As Byte)
  42.            'Create a pointer to the font data and copy the
  43.            'font data into the location in memory pointed to
  44.            fontPtr = Marshal.AllocHGlobal(fontData.Length)
  45.            Marshal.Copy(fontData, 0, fontPtr, fontData.Length)
  46.  
  47.            'Add the font to the shared collection of fonts:
  48.            fontCollection.AddMemoryFont(fontPtr, fontData.Length)
  49.        End Sub
  50. #End Region
  51.  
  52. #Region "Destructor"
  53.        'Free the font in unmanaged memory, dispose of
  54.        'the font collection and suppress finalization
  55.        Public Sub Dispose() Implements IDisposable.Dispose
  56.            Marshal.FreeHGlobal(fontPtr)
  57.            fontCollection.Dispose()
  58.  
  59.            GC.SuppressFinalize(Me)
  60.        End Sub
  61.  
  62.        'Free the font in unmanaged memory
  63.        Protected Overrides Sub Finalize()
  64.            Marshal.FreeHGlobal(fontPtr)
  65.        End Sub
  66. #End Region
  67.  
  68. #Region "Properties"
  69.        ''' <summary>
  70.        ''' Gets the font family of the custom font.
  71.        ''' </summary>
  72.        Public ReadOnly Property Font() As FontFamily
  73.            Get
  74.                Return fontCollection.Families(0)
  75.            End Get
  76.        End Property
  77. #End Region
  78.  
  79.    End Class
  80.  
  81. #End Region
  82.  
  83. #End Region





· Esperar a que una aplicación termine de CARGAR

Nota : El código no está muy simplificado, pero se puede usar y funciona bien.
Nota 2: Esto sirve para aquellas aplicaciones a las que no le afecta un "Process.WaitForInputIdle", de lo contrario es una tontería usar este code tán largo y bruto.

Ejemplo de uso:

Código
  1.    Private Sub Wait_For_Application_To_Load(ByVal APP_Path As String, Optional ByVal APP_Arguments As String = Nothing)
  2.  
  3.        Process.Start("Photoshop.exe")
  4.        Timer_CheckCPU.Tag = "Photoshop"
  5.        Timer_CheckCPU.Enabled = True
  6.        While Not Timer_CheckCPU.Tag = ""
  7.            Application.DoEvents()
  8.        End While
  9.    End Sub


Código
  1. #Region " Wait For Application To Load (UNFINISHED AND WAITING TO BE IMPROVED)"
  2.  
  3.    Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByVal lpBuffer As Integer, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
  4.    Private WithEvents Timer_CheckCPU As New Timer
  5.  
  6.    Dim Memory_Value_Changed As Boolean
  7.    Dim CPU_Changed As Boolean
  8.    Dim CPU_Time As Boolean
  9.    Dim Running_Time As Boolean
  10.    Private _desiredTime_ms As Integer = 1500
  11.  
  12.    Private Sub Timer_CheckCPU_Tick(sender As Object, ev As EventArgs) Handles Timer_CheckCPU.Tick
  13.        Timer_CheckCPU.Enabled = False
  14.        Dim pProcess() As Process = System.Diagnostics.Process.GetProcessesByName(Timer_CheckCPU.Tag)
  15.        Dim hprocess As Process = pProcess(0)
  16.        If hprocess Is Nothing Then
  17.            Running = False
  18.            Timer_CheckCPU.Enabled = True
  19.            Return
  20.        End If
  21.        Running = True
  22.        Memory = hprocess.PrivateMemorySize64
  23.        CPUTotal = hprocess.TotalProcessorTime.TotalMilliseconds
  24.  
  25.        If AllConditionsGood() Then
  26.            If Not (_countdown.IsRunning) Then
  27.                _countdown.Reset()
  28.                _countdown.Start()
  29.            End If
  30.            Dim _elapsed As Long = _countdown.ElapsedMilliseconds
  31.            If _elapsed >= _desiredTime_ms Then
  32.                Timer_CheckCPU.Tag = ""
  33.                Return
  34.            End If
  35.        Else
  36.            _countdown.Reset()
  37.        End If
  38.        Timer_CheckCPU.Enabled = True
  39.    End Sub
  40.  
  41.    Private Function AllConditionsGood() As Boolean
  42.        If CPU_Time Then Return False
  43.        If Memory_Value_Changed Then Return False
  44.        If Running_Time Then Return False
  45.        Return True
  46.    End Function
  47.  
  48.    Private _countdown As New Stopwatch
  49.  
  50.    Private _Running As Boolean = False
  51.    Public WriteOnly Property Running() As Boolean
  52.        Set(ByVal value As Boolean)
  53.            _Running = value
  54.            If value Then
  55.                Running_Time = False
  56.            Else
  57.                Running_Time = True
  58.            End If
  59.        End Set
  60.    End Property
  61.  
  62.    Private _CPUTotal As Double
  63.    Public WriteOnly Property CPUTotal() As Double
  64.        Set(ByVal value As Double)
  65.            CPU = value - _CPUTotal 'used cputime since last check
  66.            _CPUTotal = value
  67.        End Set
  68.    End Property
  69.  
  70.    Private _CPU As Double
  71.    Public WriteOnly Property CPU() As Double
  72.        Set(ByVal value As Double)
  73.            If value = 0 Then
  74.                CPU_Time = False
  75.            Else
  76.                CPU_Time = True
  77.            End If
  78.            _CPU = value
  79.        End Set
  80.    End Property
  81.  
  82.    Private _Memory As Long
  83.    Public WriteOnly Property Memory() As Long
  84.        Set(ByVal value As Long)
  85.            MemoryDiff = Math.Abs(value - _Memory)
  86.            _Memory = value
  87.        End Set
  88.    End Property
  89.  
  90.    Private _MemoryDiff As Long
  91.    Public WriteOnly Property MemoryDiff() As Long
  92.        Set(ByVal value As Long)
  93.            If value = _MemoryDiff Then
  94.                Memory_Value_Changed = False
  95.            Else
  96.                Memory_Value_Changed = True
  97.            End If
  98.            _MemoryDiff = value
  99.        End Set
  100.    End Property
  101.  
  102. #End Region
9253  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 9 Abril 2013, 20:23 pm
· Devuelve el título de la ventana de un proceso

Código
  1. #Region " Get Process Window Title Function "
  2.  
  3.    ' [ Get Process Window Title Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' MsgBox(Get_Process_Window_Title("cmd"))
  9.    ' MsgBox(Get_Process_Window_Title("cmd.exe"))
  10.  
  11.    Private Function Get_Process_Window_Title(ByVal ProcessName As String) As String
  12.        If ProcessName.ToLower.EndsWith(".exe") Then ProcessName = ProcessName.Substring(0, ProcessName.Length - 4)
  13.        Dim ProcessArray = Process.GetProcessesByName(ProcessName)
  14.        If ProcessArray.Length = 0 Then Return Nothing Else Return ProcessArray(0).MainWindowTitle
  15.    End Function
  16.  
  17. #End Region



· Devuelve el handle de un proceso
Código
  1. #Region " Get Process Handle Function "
  2.  
  3.    ' [ Get Process Handle Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' MsgBox(Get_Process_Handle("cmd"))
  9.    ' MsgBox(Get_Process_Handle("cmd.exe"))
  10.  
  11.    Private Function Get_Process_Handle(ByVal ProcessName As String) As IntPtr
  12.        If ProcessName.ToLower.EndsWith(".exe") Then ProcessName = ProcessName.Substring(0, ProcessName.Length - 4)
  13.        Dim ProcessArray = Process.GetProcessesByName(ProcessName)
  14.        If ProcessArray.Length = 0 Then Return Nothing Else Return ProcessArray(0).MainWindowHandle
  15.    End Function
  16.  
  17. #End Region



· Devuelve el PID de un proceso

Código
  1. #Region " Get Process PID Function "
  2.  
  3.    ' [ Get Process PID Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' MsgBox(Get_Process_PID("cmd"))
  9.    ' MsgBox(Get_Process_PID("cmd.exe"))
  10.  
  11.    Private Function Get_Process_PID(ByVal ProcessName As String) As IntPtr
  12.        If ProcessName.ToLower.EndsWith(".exe") Then ProcessName = ProcessName.Substring(0, ProcessName.Length - 4)
  13.        Dim ProcessArray = Process.GetProcessesByName(ProcessName)
  14.        If ProcessArray.Length = 0 Then Return Nothing Else Return ProcessArray(0).Id
  15.    End Function
  16.  
  17. #End Region
9254  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
9255  Programación / .NET (C#, VB.NET, ASP) / Sobre los Handles del SystemTray... en: 9 Abril 2013, 19:48 pm
Este tema me lleva días matándome, he creado 5 posts sobre temas relacionados con los handles en StackOverFlow, porque no me aclaro nada con las funciones de la API (FindWindow, FindWindowEx, etc...).

A ver, lo que necesito es, saber si una aplicación de terceros ha mostrado su icono en el systemtray, es decir, saber si "X" icono existe en el SysTray, ya séa buscando el icono por el handle del proceso, o por el nombre de la ventana, o como séa.

Para esto, primero intento obtener el handle de la aplicación, y luego el handle de mi systray, pero hasta aquí, ya no sé como seguir ni que debo hacer.

Código
  1. Imports System.Runtime.InteropServices
  2.  
  3. Public Class Form1
  4.  
  5.    Public Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
  6.    Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
  7.  
  8.    Public Shared Function WindowHandle(sTitle As String) As Long
  9.        Return FindWindow(vbNullString, sTitle)
  10.    End Function
  11.  
  12.    Private Shared Function GetSystemTrayHandle() As IntPtr
  13.        Dim hWndTray As IntPtr = FindWindow("Shell_TrayWnd", Nothing)
  14.        If hWndTray <> IntPtr.Zero Then
  15.            hWndTray = FindWindowEx(hWndTray, IntPtr.Zero, "TrayNotifyWnd", Nothing)
  16.            If hWndTray <> IntPtr.Zero Then
  17.                hWndTray = FindWindowEx(hWndTray, IntPtr.Zero, "SysPager", Nothing)
  18.                If hWndTray <> IntPtr.Zero Then
  19.                    hWndTray = FindWindowEx(hWndTray, IntPtr.Zero, "ToolbarWindow32", Nothing)
  20.                    Return hWndTray
  21.                End If
  22.            End If
  23.        End If
  24.  
  25.        Return IntPtr.Zero
  26.    End Function
  27.  
  28.    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  29.        MsgBox(WindowHandle("Steam")) ' 6687230
  30.        MsgBox(GetSystemTrayHandle()) ' 65728
  31.    End Sub
  32.  
  33. End Class

9256  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 9 Abril 2013, 16:50 pm
· Mostrar un MessageBox centrado al form

Código
  1. #Region " Centered Messagebox "
  2.  
  3.    ' [ Centered Messagebox Function ]
  4.    '
  5.    ' Instructions :
  6.    ' 1. Add the Class
  7.    ' 2. Use it
  8.    '
  9.    ' Examples :
  10.    ' Using New Centered_MessageBox(Me)
  11.    '     MessageBox.Show("Test Text", "Test Title", MessageBoxButtons.OK)
  12.    ' End Using
  13.  
  14.    ' Centered_MessageBox.vb
  15. #Region " Centered MessageBox Class"
  16.  
  17. Imports System.Text
  18. Imports System.Drawing
  19. Imports System.Windows.Forms
  20. Imports System.Runtime.InteropServices
  21.  
  22.    Class Centered_MessageBox
  23.        Implements IDisposable
  24.        Private mTries As Integer = 0
  25.        Private mOwner As Form
  26.  
  27.        Public Sub New(owner As Form)
  28.            mOwner = owner
  29.            owner.BeginInvoke(New MethodInvoker(AddressOf findDialog))
  30.        End Sub
  31.  
  32.        Private Sub findDialog()
  33.            ' Enumerate windows to find the message box
  34.            If mTries < 0 Then
  35.                Return
  36.            End If
  37.            Dim callback As New EnumThreadWndProc(AddressOf checkWindow)
  38.            If EnumThreadWindows(GetCurrentThreadId(), callback, IntPtr.Zero) Then
  39.                If System.Threading.Interlocked.Increment(mTries) < 10 Then
  40.                    mOwner.BeginInvoke(New MethodInvoker(AddressOf findDialog))
  41.                End If
  42.            End If
  43.        End Sub
  44.        Private Function checkWindow(hWnd As IntPtr, lp As IntPtr) As Boolean
  45.            ' Checks if <hWnd> is a dialog
  46.            Dim sb As New StringBuilder(260)
  47.            GetClassName(hWnd, sb, sb.Capacity)
  48.            If sb.ToString() <> "#32770" Then
  49.                Return True
  50.            End If
  51.            ' Got it
  52.            Dim frmRect As New Rectangle(mOwner.Location, mOwner.Size)
  53.            Dim dlgRect As RECT
  54.            GetWindowRect(hWnd, dlgRect)
  55.            MoveWindow(hWnd, frmRect.Left + (frmRect.Width - dlgRect.Right + dlgRect.Left) \ 2, frmRect.Top + (frmRect.Height - dlgRect.Bottom + dlgRect.Top) \ 2, dlgRect.Right - dlgRect.Left, dlgRect.Bottom - dlgRect.Top, True)
  56.            Return False
  57.        End Function
  58.        Public Sub Dispose() Implements IDisposable.Dispose
  59.            mTries = -1
  60.        End Sub
  61.  
  62.        ' P/Invoke declarations
  63.        Private Delegate Function EnumThreadWndProc(hWnd As IntPtr, lp As IntPtr) As Boolean
  64.        <DllImport("user32.dll")> _
  65.        Private Shared Function EnumThreadWindows(tid As Integer, callback As EnumThreadWndProc, lp As IntPtr) As Boolean
  66.        End Function
  67.        <DllImport("kernel32.dll")> _
  68.        Private Shared Function GetCurrentThreadId() As Integer
  69.        End Function
  70.        <DllImport("user32.dll")> _
  71.        Private Shared Function GetClassName(hWnd As IntPtr, buffer As StringBuilder, buflen As Integer) As Integer
  72.        End Function
  73.        <DllImport("user32.dll")> _
  74.        Private Shared Function GetWindowRect(hWnd As IntPtr, ByRef rc As RECT) As Boolean
  75.        End Function
  76.        <DllImport("user32.dll")> _
  77.        Private Shared Function MoveWindow(hWnd As IntPtr, x As Integer, y As Integer, w As Integer, h As Integer, repaint As Boolean) As Boolean
  78.        End Function
  79.        Private Structure RECT
  80.            Public Left As Integer
  81.            Public Top As Integer
  82.            Public Right As Integer
  83.            Public Bottom As Integer
  84.        End Structure
  85.    End Class
  86.  
  87. #End Region
  88.  
  89. #End Region
9257  Sistemas Operativos / Windows / Re: ¿Por que tanto odio hacia Windows 8? en: 9 Abril 2013, 15:19 pm
Cita de: gAb1
Osea que te basas en los numeros y la probabilidad para decidir si va ser bueno o no? Lo siento, pienso que deberias ser tu mismo el que juzgue y decida eso y no basarte en nada ni en lo que diga nadie más. Puede ser custión de gustos.

No, sería cuestión de números y probabilidad si el producto no se hubiese lanzado al mercado y no pudieramos testearlo.

La imagen representa mi opinión y decepción personal (como la de muchos otros), pues una imagen vale más que mil palabras.

No intentes sacar de contexto las frases que te está diciendo todo el mundo, respétalas y acepta las críticas, porque si bien habrás leido como sigue mi comentario:

Cita de: Yo
Nada más lejos que la pura realidad, yo he pasado por la época del Win95 hasta el Win8.

Así que no se donde ves una simple cuestión de números y probabilidades, cuando te estoy diciendo que he tenido en mis manos todos a lo largo d elos años, he experimentado, sufrido, y obtenido mis própias conclusiones.

Lo dicho, no saques las cosas fuera de contexto porfavor, porque esto más que un debate creo que se está convirtiendo en una ocasión personal tuya para negar todo lo que te digan o intentar darle la vuelta y llamarlos "listillos" (en fín lo que siempre suele pasar con estos posts).

PD: No sigo el tema.

Por cierto, como te gusta tanto Windows 8, quizás te interese mi post: Recopilación Windows 8 (Programas, tips y guías) (Actualizado el 05/11/2012)

Un saludo!
9258  Programación / .NET (C#, VB.NET, ASP) / ¿Usar variable en una propiedad del designer? en: 9 Abril 2013, 13:48 pm
Tengo esta variable en el form principal:

Código
  1. Dim My_Color As Color = Color.FromArgb(97, 31, 28)

El proyecto es un WinForm.

¿Hay alguna forma para usar la variable en el designer?

Lo que pretendo es que al cargar el designer, los valores de las propiedades se tomen desde mi código, ya séa con variables o de alguna otra forma.



Aquí me han dicho que no es posible: http://stackoverflow.com/questions/15900853/how-to-use-a-variable-inside-the-ide-control-properties/15900940?noredirect=1#comment22643681_15900940
Espero que alguien más pueda confirmármelo.

PD: Creo que esto si se podía hacer en los WPF.
9259  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 9 Abril 2013, 10:59 am
· Hexadecimal a Decimal:

Código
  1. #Region " Hex To Dec Function "
  2.  
  3.    ' [ Hex To Dec Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' MsgBox(Hex_To_Dec("0x020032")) ' Result: 131122
  9.  
  10.    Private Function Hex_To_Dec(ByVal str As String) As Int32
  11.        Return Convert.ToInt32(str, 16)
  12.    End Function
  13.  
  14. #End Region





· Decimal a Hexadecimal:

Código
  1. #Region " Dec To Hex Function "
  2.  
  3.    ' [ Dec To Hex Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' MsgBox(Dec_To_Hex(131122)) ' Result: 0x020032
  9.  
  10.    Private Function Dec_To_Hex(ByVal int As Int32) As String
  11.        Return Convert.ToString(int, 16)
  12.    End Function
  13.  
  14. #End Region





· Comprueba si una fuente está instalada:

EDITO: MEJORADO Y SIMPLIFICADO

#Region " Font Is Installed? Function "

    ' [ Font Is Installed? Function ]
    '
    ' // By Elektro H@cker
    '
    ' Examples :
    ' MsgBox(Font_Is_Installed("Lucida Console"))

    Private Function Font_Is_Installed(ByVal FontName As String) As Boolean
        Dim AllFonts As New Drawing.Text.InstalledFontCollection
        If AllFonts.Families.ToList().Contains(New FontFamily(FontName)) Then Return True Else Return False
    End Function

#End Region


Otra versión que me han proporcionado, mucho más simplificada:

Código
  1. #Region " Font Is Installed? Function "
  2.  
  3.    ' [ Font Is Installed? Function ]
  4.    '
  5.    ' Examples :
  6.    ' MsgBox(Font_Is_Installed("Lucida Console"))
  7.  
  8.    Public Shared Function Font_Is_Installed(ByVal FontName As String) As Boolean
  9.        Using TestFont As Font = New Font(FontName, 8)
  10.            Return CBool(String.Compare(FontName, TestFont.Name, StringComparison.InvariantCultureIgnoreCase) = 0)
  11.        End Using
  12.    End Function
  13.  
  14. #End Region
9260  Programación / .NET (C#, VB.NET, ASP) / Re: Corrector ortográfico ¿Se puede realizar en VB.NET? en: 9 Abril 2013, 09:41 am
Hola

Yo nunca he tocado ese tema, pero respondiendo a tu pregunta... poder, se puede.
Obviamente necesitas un diccionario (imagino que al ser de Microsoft podrás usar los diccionarios de MS Word para tener un super-corrector), el resto no sé exáctamente como se hace, pero a parte de la ayuda que te puedan dar, te dejo unos ejemplos que te pueden servir!:

http://www.codeproject.com/Articles/265823/i00-Spell-Check-and-Control-Extensions-No-Third-Pa

http://www.freevbcode.com/ShowCode.asp?ID=7685

http://www.c-sharpcorner.com/UploadFile/scottlysle/visual-basic-spell-check-enabled-rich-text-box-custom-contro/

http://www.codeproject.com/Articles/878/A-free-Spell-Checker-with-a-dictionary-editor-prog

Busca en Google por "grammar check" y "spell check"
https://www.google.com/search?q=vbnet+spell+check&ie=utf-8&oe=utf-8&lr=lang_en

Saludos!
Páginas: 1 ... 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 [926] 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 ... 1236
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines