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


Tema destacado: Sigue las noticias más importantes de seguridad informática en el Twitter! de elhacker.NET


  Mostrar Mensajes
Páginas: 1 ... 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 [911] 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 ... 1254
9101  Sistemas Operativos / Windows / Re: Archivo Host Modificarlo en: 5 Junio 2013, 16:24 pm
He cogido el block de notas y lo he abierto como administrador pero como el archivo esta en modo lectura no he podido modificarlo.

¿Alguna otra forma de quitar el modo lectura de ese archivo?

Click derecho sobre el archivo "hosts", y pinchas en la casilla "Solo lectura" para desactivarlo...

Código
  1. Attrib -r "hosts"

Salu2!
9102  Sistemas Operativos / Windows / Re: Línea de comandos en windows. en: 5 Junio 2013, 16:20 pm
He intentado hacer funcionar aircrack dado doble click pero se abre y a los 2 segundos se cierra.

¿quiere eso decir que debo usar la línea de comandos?

Aircrack es una suite de aplicaciones commandline, efectivamente tienes que usarlas por consola,
Te puedes descargar el AirCrack-ng GUI, que como su nombre indica es una GUI (Graphical User Interface), y ya no necesitarás usar aircrack por consola.

Saludos.
9103  Programación / .NET (C#, VB.NET, ASP) / Re: [C#] Ocultar varios groupbox en: 4 Junio 2013, 22:04 pm
Gracias, pero, ¿no hay manera de ocultar sólo los "grpEx*" sin tener que recorrer todos los groupboxes? Es para optimizar un poco

No, hay que hacer la iteración de los controles uno por uno,
Otra forma sería que todos esos groupboxes los metieses en un nuevo panel (Dentro del panel que ya estás usando), y entonces haces un simple "NuevoPanel.visible = false"

EDITO:
Código
  1. If TypeOf Control Is GroupBox andalso Control.name.startswith("grpEx") then...

Saludos!
9104  Programación / .NET (C#, VB.NET, ASP) / Re: [C#] Ocultar varios groupbox en: 4 Junio 2013, 21:57 pm
Te lo he hecho en VBNET, no es nada dificil convertirlo a C#:

Código
  1.    Public Sub Disable_Groupboxes(ByVal Container As ControlCollection, ByVal Visible As Boolean)
  2.        For Each Control As Control In Container
  3.            If TypeOf Control Is GroupBox Then Control.Visible = Visible
  4.        Next
  5.    End Sub

Código
  1. Disable_Groupboxes(Me.Controls, False)

http://converter.telerik.com/

Saludos!
9105  Programación / Programación General / Re: Duda sobre lenguajes en: 4 Junio 2013, 21:42 pm
No sé si me entiendes... no quiero que el lenguaje acepte que cada uno organice el código como le salga de las narices (cosa que Python no hace, sólo daba un ejemplo)

Ahora lo entiendo mejor, creia que solo estaba relacionado con los espacios de los comentarios,
pues VB.NET no permite escribir nada con espacios (ningún keyword), si escribes espacios demás te lo organiza automáticamente, séa lo que séa, menos cadenas de strings cerradas con comillas dobles (obvio) xD.

Pruébalo!

Un saludo.
9106  Programación / Programación General / Re: Duda sobre lenguajes en: 4 Junio 2013, 21:25 pm
No entiendo la lógica de la pregunta.

Python:
Código
  1. print "Hola" # Perfectamente valido...

Los lenguajes permiten líneas de comentario, ya sea encima del bloque, debajo, o al final de una línea,
De hecho unos buenos comentarios es lo que perfecciona la organización del código en si mismo.

De verdad, yo no lo véo lógica a la pregunta, o a lo mejor es que he entendido mal...

...pero desde luego si yo supiera C# hasta cierto punto, ni loco me cambiaria por un lenguaje de scripting, aunque séa Python, de hecho el que menos sería Python porque es demasiado restrictivo y para escribir códigos cortos a lo "pseudo" o para escribir 4 tonterías para probar una cosa pequeña te puedes tirar varios minutos corrigiendo ya que hay que escribirlo todo sin imperfecciones, al más mínimo detalle, sin poder equivocarse en el margen de ni un solo espacio! ...Python será organizado, pero desde luego no lo considero productivo, a la larga hace perder el tiempo.

Saludos!
9107  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 4 Junio 2013, 20:41 pm
Taskbar Hide-Show

Oculta o desoculta la barra de tareas de Windows.

Código
  1. #Region " Taskbar Hide-Show "
  2.  
  3. ' [ Taskbar Hide-Show]
  4. '
  5. ' Examples :
  6. '
  7. ' Taskbar.Hide()
  8. ' Taskbar.Show()
  9.  
  10. #End Region
  11.  
  12. ' Taskbar.vb
  13. #Region " Taskbar Class "
  14.  
  15. ''' <summary>
  16. ''' Helper class for hiding/showing the taskbar and startmenu on
  17. ''' Windows XP and Vista.
  18. ''' </summary>
  19. Public Class Taskbar
  20.  
  21.    <System.Runtime.InteropServices.DllImport("user32.dll")> _
  22.    Private Shared Function GetWindowText(hWnd As IntPtr, text As System.Text.StringBuilder, count As Integer) As Integer
  23.    End Function
  24.    <System.Runtime.InteropServices.DllImport("user32.dll", CharSet:=System.Runtime.InteropServices.CharSet.Auto)> _
  25.    Private Shared Function EnumThreadWindows(threadId As Integer, pfnEnum As EnumThreadProc, lParam As IntPtr) As Boolean
  26.    End Function
  27.    <System.Runtime.InteropServices.DllImport("user32.dll", SetLastError:=True)> _
  28.    Private Shared Function FindWindow(lpClassName As String, lpWindowName As String) As System.IntPtr
  29.    End Function
  30.    <System.Runtime.InteropServices.DllImport("user32.dll", SetLastError:=True)> _
  31.    Private Shared Function FindWindowEx(parentHandle As IntPtr, childAfter As IntPtr, className As String, windowTitle As String) As IntPtr
  32.    End Function
  33.    <System.Runtime.InteropServices.DllImport("user32.dll")> _
  34.    Private Shared Function FindWindowEx(parentHwnd As IntPtr, childAfterHwnd As IntPtr, className As IntPtr, windowText As String) As IntPtr
  35.    End Function
  36.    <System.Runtime.InteropServices.DllImport("user32.dll")> _
  37.    Private Shared Function ShowWindow(hwnd As IntPtr, nCmdShow As Integer) As Integer
  38.    End Function
  39.    <System.Runtime.InteropServices.DllImport("user32.dll")> _
  40.    Private Shared Function GetWindowThreadProcessId(hwnd As IntPtr, lpdwProcessId As Integer) As UInteger
  41.    End Function
  42.  
  43.    Private Const SW_HIDE As Integer = 0
  44.    Private Const SW_SHOW As Integer = 5
  45.  
  46.    Private Const VistaStartMenuCaption As String = "Start"
  47.    Private Shared vistaStartMenuWnd As IntPtr = IntPtr.Zero
  48.    Private Delegate Function EnumThreadProc(hwnd As IntPtr, lParam As IntPtr) As Boolean
  49.  
  50.    ''' <summary>
  51.    ''' Show the taskbar.
  52.    ''' </summary>
  53.    Public Shared Sub Show()
  54.        SetVisibility(True)
  55.    End Sub
  56.  
  57.    ''' <summary>
  58.    ''' Hide the taskbar.
  59.    ''' </summary>
  60.    Public Shared Sub Hide()
  61.        SetVisibility(False)
  62.    End Sub
  63.  
  64.    ''' <summary>
  65.    ''' Sets the visibility of the taskbar.
  66.    ''' </summary>
  67.    Private Shared WriteOnly Property Visible() As Boolean
  68.        Set(value As Boolean)
  69.            SetVisibility(value)
  70.        End Set
  71.    End Property
  72.  
  73.    ''' <summary>
  74.    ''' Hide or show the Windows taskbar and startmenu.
  75.    ''' </summary>
  76.    ''' <param name="show">true to show, false to hide</param>
  77.    Private Shared Sub SetVisibility(show As Boolean)
  78.        ' get taskbar window
  79.        Dim taskBarWnd As IntPtr = FindWindow("Shell_TrayWnd", Nothing)
  80.  
  81.        ' Try the Windows XP TaskBar:
  82.        Dim startWnd As IntPtr = FindWindowEx(taskBarWnd, IntPtr.Zero, "Button", "Start")
  83.  
  84.        If startWnd = IntPtr.Zero Then
  85.            ' Try an alternate way of Windows XP TaskBar:
  86.            startWnd = FindWindowEx(IntPtr.Zero, IntPtr.Zero, CType(&HC017, IntPtr), "Start")
  87.        End If
  88.  
  89.        If startWnd = IntPtr.Zero Then
  90.            ' Try the Windows Vista/7 TaskBar:
  91.            startWnd = FindWindow("Button", Nothing)
  92.  
  93.            If startWnd = IntPtr.Zero Then
  94.                ' Try an alternate way of Windows Vista/7 TaskBar:
  95.                startWnd = GetVistaStartMenuWnd(taskBarWnd)
  96.            End If
  97.        End If
  98.  
  99.        ShowWindow(taskBarWnd, If(show, SW_SHOW, SW_HIDE))
  100.        ShowWindow(startWnd, If(show, SW_SHOW, SW_HIDE))
  101.  
  102.    End Sub
  103.  
  104.    ''' <summary>
  105.    ''' Returns the window handle of the Vista start menu orb.
  106.    ''' </summary>
  107.    ''' <param name="taskBarWnd">windo handle of taskbar</param>
  108.    ''' <returns>window handle of start menu</returns>
  109.    Private Shared Function GetVistaStartMenuWnd(taskBarWnd As IntPtr) As IntPtr
  110.        ' get process that owns the taskbar window
  111.        Dim procId As Integer
  112.        GetWindowThreadProcessId(taskBarWnd, procId)
  113.  
  114.        Dim p As Process = Process.GetProcessById(procId)
  115.        If p IsNot Nothing Then
  116.            ' enumerate all threads of that process...
  117.            For Each t As ProcessThread In p.Threads
  118.                EnumThreadWindows(t.Id, AddressOf MyEnumThreadWindowsProc, IntPtr.Zero)
  119.            Next
  120.        End If
  121.        Return vistaStartMenuWnd
  122.    End Function
  123.  
  124.    ''' <summary>
  125.    ''' Callback method that is called from 'EnumThreadWindows' in 'GetVistaStartMenuWnd'.
  126.    ''' </summary>
  127.    ''' <param name="hWnd">window handle</param>
  128.    ''' <param name="lParam">parameter</param>
  129.    ''' <returns>true to continue enumeration, false to stop it</returns>
  130.    Private Shared Function MyEnumThreadWindowsProc(hWnd As IntPtr, lParam As IntPtr) As Boolean
  131.        Dim buffer As New System.Text.StringBuilder(256)
  132.        If GetWindowText(hWnd, buffer, buffer.Capacity) > 0 Then
  133.            Console.WriteLine(buffer)
  134.            If buffer.ToString() = VistaStartMenuCaption Then
  135.                vistaStartMenuWnd = hWnd
  136.                Return False
  137.            End If
  138.        End If
  139.        Return True
  140.    End Function
  141.  
  142. End Class
  143.  
  144. #End Region
9108  Programación / .NET (C#, VB.NET, ASP) / Re: Ayuda para traducir una función anónima de C# a VBNET en: 4 Junio 2013, 20:13 pm
Bueno, aquí les dejo el código convertido a vbnet, ya lo conseguí:

Código
  1. Imports System
  2. Imports System.Text
  3. Imports System.Runtime.InteropServices
  4. Imports System.Diagnostics
  5.  
  6. Namespace TaskbarHide
  7.    ''' <summary>
  8.    ''' Helper class for hiding/showing the taskbar and startmenu on
  9.    ''' Windows XP and Vista.
  10.    ''' </summary>
  11.    Public NotInheritable Class Taskbar
  12.        Private Sub New()
  13.        End Sub
  14.        <DllImport("user32.dll")> _
  15.        Private Shared Function GetWindowText(hWnd As IntPtr, text As StringBuilder, count As Integer) As Integer
  16.        End Function
  17.        <DllImport("user32.dll", CharSet:=CharSet.Auto)> _
  18.        Private Shared Function EnumThreadWindows(threadId As Integer, pfnEnum As EnumThreadProc, lParam As IntPtr) As Boolean
  19.        End Function
  20.        <DllImport("user32.dll", SetLastError:=True)> _
  21.        Private Shared Function FindWindow(lpClassName As String, lpWindowName As String) As System.IntPtr
  22.        End Function
  23.        <DllImport("user32.dll", SetLastError:=True)> _
  24.        Private Shared Function FindWindowEx(parentHandle As IntPtr, childAfter As IntPtr, className As String, windowTitle As String) As IntPtr
  25.        End Function
  26.        <DllImport("user32.dll")> _
  27.        Private Shared Function FindWindowEx(parentHwnd As IntPtr, childAfterHwnd As IntPtr, className As IntPtr, windowText As String) As IntPtr
  28.        End Function
  29.        <DllImport("user32.dll")> _
  30.        Private Shared Function ShowWindow(hwnd As IntPtr, nCmdShow As Integer) As Integer
  31.        End Function
  32.        <DllImport("user32.dll")> _
  33.        Private Shared Function GetWindowThreadProcessId(hwnd As IntPtr, lpdwProcessId As Integer) As UInteger
  34.        End Function
  35.  
  36.        Private Const SW_HIDE As Integer = 0
  37.        Private Const SW_SHOW As Integer = 5
  38.  
  39.        Private Const VistaStartMenuCaption As String = "Start"
  40.        Private Shared vistaStartMenuWnd As IntPtr = IntPtr.Zero
  41.        Private Delegate Function EnumThreadProc(hwnd As IntPtr, lParam As IntPtr) As Boolean
  42.  
  43.        ''' <summary>
  44.        ''' Show the taskbar.
  45.        ''' </summary>
  46.        Public Shared Sub Show()
  47.            SetVisibility(True)
  48.        End Sub
  49.  
  50.        ''' <summary>
  51.        ''' Hide the taskbar.
  52.        ''' </summary>
  53.        Public Shared Sub Hide()
  54.            SetVisibility(False)
  55.        End Sub
  56.  
  57.        ''' <summary>
  58.        ''' Sets the visibility of the taskbar.
  59.        ''' </summary>
  60.        Public Shared WriteOnly Property Visible() As Boolean
  61.            Set(value As Boolean)
  62.                SetVisibility(value)
  63.            End Set
  64.        End Property
  65.  
  66.        ''' <summary>
  67.        ''' Hide or show the Windows taskbar and startmenu.
  68.        ''' </summary>
  69.        ''' <param name="show">true to show, false to hide</param>
  70.        Private Shared Sub SetVisibility(show As Boolean)
  71.            ' get taskbar window
  72.            Dim taskBarWnd As IntPtr = FindWindow("Shell_TrayWnd", Nothing)
  73.  
  74.            ' try it the WinXP way first...
  75.            Dim startWnd As IntPtr = FindWindowEx(taskBarWnd, IntPtr.Zero, "Button", "Start")
  76.  
  77.            If startWnd = IntPtr.Zero Then
  78.                ' try an alternate way, as mentioned on CodeProject by Earl Waylon Flinn
  79.                startWnd = FindWindowEx(IntPtr.Zero, IntPtr.Zero, CType(&HC017, IntPtr), "Start")
  80.            End If
  81.  
  82.            If startWnd = IntPtr.Zero Then
  83.                ' ok, let's try the Vista easy way...
  84.                startWnd = FindWindow("Button", Nothing)
  85.  
  86.                If startWnd = IntPtr.Zero Then
  87.                    ' no chance, we need to to it the hard way...
  88.                    startWnd = GetVistaStartMenuWnd(taskBarWnd)
  89.                End If
  90.            End If
  91.  
  92.            ShowWindow(taskBarWnd, If(show, SW_SHOW, SW_HIDE))
  93.            ShowWindow(startWnd, If(show, SW_SHOW, SW_HIDE))
  94.        End Sub
  95.  
  96.        ''' <summary>
  97.        ''' Returns the window handle of the Vista start menu orb.
  98.        ''' </summary>
  99.        ''' <param name="taskBarWnd">windo handle of taskbar</param>
  100.        ''' <returns>window handle of start menu</returns>
  101.        Private Shared Function GetVistaStartMenuWnd(taskBarWnd As IntPtr) As IntPtr
  102.            ' get process that owns the taskbar window
  103.            Dim procId As Integer
  104.            GetWindowThreadProcessId(taskBarWnd, procId)
  105.  
  106.            Dim p As Process = Process.GetProcessById(procId)
  107.            If p IsNot Nothing Then
  108.                ' enumerate all threads of that process...
  109.                For Each t As ProcessThread In p.Threads
  110.                    EnumThreadWindows(t.Id, AddressOf MyEnumThreadWindowsProc, IntPtr.Zero)
  111.                Next
  112.            End If
  113.            Return vistaStartMenuWnd
  114.        End Function
  115.  
  116.        ''' <summary>
  117.        ''' Callback method that is called from 'EnumThreadWindows' in 'GetVistaStartMenuWnd'.
  118.        ''' </summary>
  119.        ''' <param name="hWnd">window handle</param>
  120.        ''' <param name="lParam">parameter</param>
  121.        ''' <returns>true to continue enumeration, false to stop it</returns>
  122.        Private Shared Function MyEnumThreadWindowsProc(hWnd As IntPtr, lParam As IntPtr) As Boolean
  123.            Dim buffer As New StringBuilder(256)
  124.            If GetWindowText(hWnd, buffer, buffer.Capacity) > 0 Then
  125.                Console.WriteLine(buffer)
  126.                If buffer.ToString() = VistaStartMenuCaption Then
  127.                    vistaStartMenuWnd = hWnd
  128.                    Return False
  129.                End If
  130.            End If
  131.            Return True
  132.        End Function
  133.    End Class
  134. End Namespace
9109  Programación / .NET (C#, VB.NET, ASP) / Ayuda para traducir una función anónima de C# a VBNET en: 4 Junio 2013, 19:19 pm
Hola

No puedo hallar la manera de traducir esta línea de código por mi mismo, espero que puedan ayudarme.

El problema es en este For, que se usa la función anónima "MyEnumThreadWindowsProc" como un argumento, sin pasarle argumentos a dicha función, y esto no sé traducirlo a VBNET.

Código
  1. foreach (ProcessThread t in p.Threads)
  2. {
  3.  EnumThreadWindows(t.Id, MyEnumThreadWindowsProc, IntPtr.Zero);
  4. }

Los traductores no saben traducirlo corréctamente, y obtengo este reusltado:

Código
  1. For Each t As ProcessThread In p.Threads
  2.  EnumThreadWindows(t.Id, MyEnumThreadWindowsProc, IntPtr.Zero)
  3. Next

Según una persona me ha comentado hace poco, esto podría ser una solución:
Código
  1.   For Each t As ProcessThread In p.Threads
  2.  Dim returnMyEnumThreadWindowsProc As Object
  3.  returnMyEnumThreadWindowsProc = MyEnumThreadWindowsProc ( ... )
  4.  EnumThreadWindows(t.Id, returnMyEnumThreadWindowsProc , IntPtr.Zero)
  5. Next

...Pero aún así sigo con el problema de no saber que parámetros enviarle a "MyEnumThreadWindowsProc " en esa última modificación.



Aquí tienen la class de C#:
Código
  1. using System;
  2. using System.Text;
  3. using System.Runtime.InteropServices;
  4. using System.Diagnostics;
  5.  
  6. namespace TaskbarHide
  7. {
  8.    /// <summary>
  9.    /// Helper class for hiding/showing the taskbar and startmenu on
  10.    /// Windows XP and Vista.
  11.    /// </summary>
  12.    public static class Taskbar
  13.    {
  14.        [DllImport("user32.dll")]
  15.        private static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int count);
  16.        [DllImport("user32.dll", CharSet = CharSet.Auto)]
  17.        private static extern bool EnumThreadWindows(int threadId, EnumThreadProc pfnEnum, IntPtr lParam);
  18.        [DllImport("user32.dll", SetLastError = true)]
  19.        private static extern System.IntPtr FindWindow(string lpClassName, string lpWindowName);
  20.        [DllImport("user32.dll", SetLastError = true)]
  21.        private static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string className,  string windowTitle);
  22.        [DllImport("user32.dll")]
  23.        private static extern IntPtr FindWindowEx(IntPtr parentHwnd, IntPtr childAfterHwnd, IntPtr className, string windowText);
  24.        [DllImport("user32.dll")]
  25.        private static extern int ShowWindow(IntPtr hwnd, int nCmdShow);
  26.        [DllImport("user32.dll")]
  27.        private static extern uint GetWindowThreadProcessId(IntPtr hwnd, out int lpdwProcessId);
  28.  
  29.        private const int SW_HIDE = 0;
  30.        private const int SW_SHOW = 5;
  31.  
  32.        private const string VistaStartMenuCaption = "Start";
  33.        private static IntPtr vistaStartMenuWnd = IntPtr.Zero;
  34.        private delegate bool EnumThreadProc(IntPtr hwnd, IntPtr lParam);
  35.  
  36.        /// <summary>
  37.        /// Show the taskbar.
  38.        /// </summary>
  39.        public static void Show()
  40.        {
  41.            SetVisibility(true);
  42.        }
  43.  
  44.        /// <summary>
  45.        /// Hide the taskbar.
  46.        /// </summary>
  47.        public static void Hide()
  48.        {
  49.            SetVisibility(false);
  50.        }
  51.  
  52.        /// <summary>
  53.        /// Sets the visibility of the taskbar.
  54.        /// </summary>
  55.        public static bool Visible
  56.        {
  57.            set { SetVisibility(value); }
  58.        }
  59.  
  60.        /// <summary>
  61.        /// Hide or show the Windows taskbar and startmenu.
  62.        /// </summary>
  63.        /// <param name="show">true to show, false to hide</param>
  64.        private static void SetVisibility(bool show)
  65.        {
  66.            // get taskbar window
  67.            IntPtr taskBarWnd = FindWindow("Shell_TrayWnd", null);
  68.  
  69.            // try it the WinXP way first...
  70.            IntPtr startWnd = FindWindowEx(taskBarWnd, IntPtr.Zero, "Button", "Start");
  71.  
  72.            if (startWnd == IntPtr.Zero)
  73.            {
  74.                // try an alternate way, as mentioned on CodeProject by Earl Waylon Flinn
  75.                startWnd = FindWindowEx(IntPtr.Zero, IntPtr.Zero, (IntPtr)0xC017, "Start");
  76.            }
  77.  
  78.            if (startWnd == IntPtr.Zero)
  79.            {
  80.                // ok, let's try the Vista easy way...
  81.                startWnd = FindWindow("Button", null);
  82.  
  83.                if (startWnd == IntPtr.Zero)
  84.                {
  85.                    // no chance, we need to to it the hard way...
  86.                    startWnd = GetVistaStartMenuWnd(taskBarWnd);
  87.                }
  88.            }
  89.  
  90.            ShowWindow(taskBarWnd, show ? SW_SHOW : SW_HIDE);
  91.            ShowWindow(startWnd, show ? SW_SHOW : SW_HIDE);
  92.        }
  93.  
  94.        /// <summary>
  95.        /// Returns the window handle of the Vista start menu orb.
  96.        /// </summary>
  97.        /// <param name="taskBarWnd">windo handle of taskbar</param>
  98.        /// <returns>window handle of start menu</returns>
  99.        private static IntPtr GetVistaStartMenuWnd(IntPtr taskBarWnd)
  100.        {
  101.            // get process that owns the taskbar window
  102.            int procId;
  103.            GetWindowThreadProcessId(taskBarWnd, out procId);
  104.  
  105.            Process p = Process.GetProcessById(procId);
  106.            if (p != null)
  107.            {
  108.                // enumerate all threads of that process...
  109.                foreach (ProcessThread t in p.Threads)
  110.                {
  111.                    EnumThreadWindows(t.Id, MyEnumThreadWindowsProc, IntPtr.Zero);
  112.                }
  113.            }
  114.            return vistaStartMenuWnd;
  115.        }
  116.  
  117.        /// <summary>
  118.        /// Callback method that is called from 'EnumThreadWindows' in 'GetVistaStartMenuWnd'.
  119.        /// </summary>
  120.        /// <param name="hWnd">window handle</param>
  121.        /// <param name="lParam">parameter</param>
  122.        /// <returns>true to continue enumeration, false to stop it</returns>
  123.        private static bool MyEnumThreadWindowsProc(IntPtr hWnd, IntPtr lParam)
  124.        {
  125.            StringBuilder buffer = new StringBuilder(256);
  126.            if (GetWindowText(hWnd, buffer, buffer.Capacity) > 0)
  127.            {
  128.                Console.WriteLine(buffer);
  129.                if (buffer.ToString() == VistaStartMenuCaption)
  130.                {
  131.                    vistaStartMenuWnd = hWnd;
  132.                    return false;
  133.                }
  134.            }
  135.            return true;
  136.        }
  137.    }
  138. }



Y aquí la class "traducida":

Código
  1. '
  2. ' * Copyright (c) 2008..11 by Simon Baer
  3. ' *
  4. ' *  You may use this code for whatever you want.
  5. '
  6.  
  7.  
  8. Imports System
  9. Imports System.Text
  10. Imports System.Runtime.InteropServices
  11. Imports System.Diagnostics
  12.  
  13. Namespace TaskbarHide
  14.    ''' <summary>
  15.    ''' Helper class for hiding/showing the taskbar and startmenu on
  16.    ''' Windows XP and Vista.
  17.    ''' </summary>
  18.    Public NotInheritable Class Taskbar
  19.        Private Sub New()
  20.        End Sub
  21.        <DllImport("user32.dll")> _
  22.        Private Shared Function GetWindowText(hWnd As IntPtr, text As StringBuilder, count As Integer) As Integer
  23.        End Function
  24.        <DllImport("user32.dll", CharSet := CharSet.Auto)> _
  25.        Private Shared Function EnumThreadWindows(threadId As Integer, pfnEnum As EnumThreadProc, lParam As IntPtr) As Boolean
  26.        End Function
  27.        <DllImport("user32.dll", SetLastError := True)> _
  28.        Private Shared Function FindWindow(lpClassName As String, lpWindowName As String) As System.IntPtr
  29.        End Function
  30.        <DllImport("user32.dll", SetLastError := True)> _
  31.        Private Shared Function FindWindowEx(parentHandle As IntPtr, childAfter As IntPtr, className As String, windowTitle As String) As IntPtr
  32.        End Function
  33.        <DllImport("user32.dll")> _
  34.        Private Shared Function FindWindowEx(parentHwnd As IntPtr, childAfterHwnd As IntPtr, className As IntPtr, windowText As String) As IntPtr
  35.        End Function
  36.        <DllImport("user32.dll")> _
  37.        Private Shared Function ShowWindow(hwnd As IntPtr, nCmdShow As Integer) As Integer
  38.        End Function
  39.        <DllImport("user32.dll")> _
  40.        Private Shared Function GetWindowThreadProcessId(hwnd As IntPtr, lpdwProcessId As Integer) As UInteger
  41.        End Function
  42.  
  43.        Private Const SW_HIDE As Integer = 0
  44.        Private Const SW_SHOW As Integer = 5
  45.  
  46.        Private Const VistaStartMenuCaption As String = "Start"
  47.        Private Shared vistaStartMenuWnd As IntPtr = IntPtr.Zero
  48.        Private Delegate Function EnumThreadProc(hwnd As IntPtr, lParam As IntPtr) As Boolean
  49.  
  50.        ''' <summary>
  51.        ''' Show the taskbar.
  52.        ''' </summary>
  53.        Public Shared Sub Show()
  54.            SetVisibility(True)
  55.        End Sub
  56.  
  57.        ''' <summary>
  58.        ''' Hide the taskbar.
  59.        ''' </summary>
  60.        Public Shared Sub Hide()
  61.            SetVisibility(False)
  62.        End Sub
  63.  
  64.        ''' <summary>
  65.        ''' Sets the visibility of the taskbar.
  66.        ''' </summary>
  67.        Public Shared WriteOnly Property Visible() As Boolean
  68.            Set
  69.                SetVisibility(value)
  70.            End Set
  71.        End Property
  72.  
  73.        ''' <summary>
  74.        ''' Hide or show the Windows taskbar and startmenu.
  75.        ''' </summary>
  76.        ''' <param name="show">true to show, false to hide</param>
  77.        Private Shared Sub SetVisibility(show As Boolean)
  78.            ' get taskbar window
  79.            Dim taskBarWnd As IntPtr = FindWindow("Shell_TrayWnd", Nothing)
  80.  
  81.            ' try it the WinXP way first...
  82.            Dim startWnd As IntPtr = FindWindowEx(taskBarWnd, IntPtr.Zero, "Button", "Start")
  83.  
  84.            If startWnd = IntPtr.Zero Then
  85.                ' try an alternate way, as mentioned on CodeProject by Earl Waylon Flinn
  86.                startWnd = FindWindowEx(IntPtr.Zero, IntPtr.Zero, DirectCast(&Hc017, IntPtr), "Start")
  87.            End If
  88.  
  89.            If startWnd = IntPtr.Zero Then
  90.                ' ok, let's try the Vista easy way...
  91.                startWnd = FindWindow("Button", Nothing)
  92.  
  93.                If startWnd = IntPtr.Zero Then
  94.                    ' no chance, we need to to it the hard way...
  95.                    startWnd = GetVistaStartMenuWnd(taskBarWnd)
  96.                End If
  97.            End If
  98.  
  99.            ShowWindow(taskBarWnd, If(show, SW_SHOW, SW_HIDE))
  100.            ShowWindow(startWnd, If(show, SW_SHOW, SW_HIDE))
  101.        End Sub
  102.  
  103.        ''' <summary>
  104.        ''' Returns the window handle of the Vista start menu orb.
  105.        ''' </summary>
  106.        ''' <param name="taskBarWnd">windo handle of taskbar</param>
  107.        ''' <returns>window handle of start menu</returns>
  108.        Private Shared Function GetVistaStartMenuWnd(taskBarWnd As IntPtr) As IntPtr
  109.            ' get process that owns the taskbar window
  110.            Dim procId As Integer
  111.            GetWindowThreadProcessId(taskBarWnd, procId)
  112.  
  113.            Dim p As Process = Process.GetProcessById(procId)
  114.            If p IsNot Nothing Then
  115.                ' enumerate all threads of that process...
  116.                For Each t As ProcessThread In p.Threads
  117.                    EnumThreadWindows(t.Id, MyEnumThreadWindowsProc, IntPtr.Zero)
  118.                Next
  119.            End If
  120.            Return vistaStartMenuWnd
  121.        End Function
  122.  
  123.        ''' <summary>
  124.        ''' Callback method that is called from 'EnumThreadWindows' in 'GetVistaStartMenuWnd'.
  125.        ''' </summary>
  126.        ''' <param name="hWnd">window handle</param>
  127.        ''' <param name="lParam">parameter</param>
  128.        ''' <returns>true to continue enumeration, false to stop it</returns>
  129.        Private Shared Function MyEnumThreadWindowsProc(hWnd As IntPtr, lParam As IntPtr) As Boolean
  130.            Dim buffer As New StringBuilder(256)
  131.            If GetWindowText(hWnd, buffer, buffer.Capacity) > 0 Then
  132.                Console.WriteLine(buffer)
  133.                If buffer.ToString() = VistaStartMenuCaption Then
  134.                    vistaStartMenuWnd = hWnd
  135.                    Return False
  136.                End If
  137.            End If
  138.            Return True
  139.        End Function
  140.    End Class
  141. End Namespace
  142.  
  143. '=======================================================
  144. 'Service provided by Telerik (www.telerik.com)
  145. 'Conversion powered by NRefactory.
  146. 'Twitter: @telerik, @toddanglin
  147. 'Facebook: facebook.com/telerik
  148. '=======================================================
9110  Programación / .NET (C#, VB.NET, ASP) / Re: Mostrar/Ocultar en: 4 Junio 2013, 19:05 pm
Edito, es codigo de C#

XD tendre que pasarlo a VB.NET

Haz una dll con esa class "taskbar.cs" y luego referencias la dll a tu proyecto y listo.

No intentes traducir el code a VB, no vas a saber ni a poder hacerlo, los traductores online no saben traducirlo,
En el code de C# se llama a una función sin parámetros como si fuese un parámetro en si mismo, y eso en VB no sé como sería el equivalente.

Creo que haré una pregunta sobre como traducir ese maldita código ...sino posteas tu la misma pregunta antes que yo xD
Páginas: 1 ... 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 [911] 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 ... 1254
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines