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

 

 


Tema destacado: Usando Git para manipular el directorio de trabajo, el índice y commits (segunda parte)


  Mostrar Mensajes
Páginas: 1 ... 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 927 928 929 ... 1232
9131  Programación / Programación General / Re: Ayuda , error de compilacion: else sin if ?? en: 30 Abril 2013, 18:20 pm
Por desgracia aún no he desarrollado vista de águila, puedes copiar el código de la condicional o subir una imagen a tamaño real?, gracias.

Saludos.
9132  Sistemas Operativos / Windows / Re: Cambiar las rutas de varios directorios para congelar windows en: 30 Abril 2013, 18:12 pm
¿Mover las carpetas del sistema a otra partición (menos la de "Windows") y especificar esa partición como partición de sistema mediante el registro?, ese debe ser el sueño de todo lammer que hace virus para joder el el arranque del SO xD.

Puedes modificar la partición actual del sistema con "BCDEdit" o con "Easy BCD" sin ir más lejos, puedes hacer todos los cambios relevantes que quieras, pero lo que planteas no puedes hacerlo y no creo que nunca vaya a ser porislbe en un futuro.

· Las carpetas del sistema, por algo se llaman "de sistema".

· Los perfiles de usuario se generan en la partición de sistema, no en una partición activa.

· Las variables de entorno de Windows apuntan a directorios de la partición de sistema (APPDATA LOCALAPPDATA USERPROFILE SYSTEMROOT, etc...), y hasta donde yo sé no puedes modificar sus localizaciones (sólamente la localización de la avriable TEMP), y son las variables en las que se basan TODOS los programas, así que un programa que ejecutes en "D:" no va a buscar en esa partición, ni tampoco va a crear los archivos necesarios en esa partición.

· Todas las carpetas como "Escritorio" "mi música" "documentos" tienen su ruta especificada en el regedit así que si las mueves la cagas, aunque obviamente puedes cambiar las rutas especificadas en el regedit, vale, pero la idea es que si se modifican las rutas esas rutas sigan apuntando a un directorio de la partición de sistema.

· Los programas suelen guardar sus configuración en la ruta "...\roaming" de la partición del sistema.

· Existen unas dll's y archivos compartidos por el sistema en la ruta "\...\program files\common files\...", que están en la partición del sistema, no en la partición activa, así que eso daría como resultado un montón de claves inválidas (que podrías ver al usar ccleaner por ejemplo), claves que deberías editar las rutas hacia esos archivos compartidos en el regedit.

· También hay programas necesarios por Windows en la carpeta Program files (y x86), con que le heches un ojo sabrás cuales son.

· La carpeta programdata contiene información vital quizás no para el inicio dle SO, pero si para su uso, archivos temporales de caché de Windows, accesos directos del menú inicio, la caché de imágenes, etc, así como las configuraciones de los programas instalados, aunque los instales en otra partición. y aunque consiguieras mover esta carpeta (que no puedes), Windows depende de ella así que la intentaría generar en la partición del SISTEMA, igual que todas las demás carpetas que quieres mover, pero eso no pasará ni en el mejor de los casos, lo que pasaría es que no podrías arrancar el SO si mueves todas esas carpetas, diréctamente te saldria reparación del sistema.

· Muchos de los archivos que se encuentran en las distintas carpetas que quieres mover, estarán en uso por el sistema operativo así que no podrás ni moverlos, tendrías que copiarlos.

Y así podría seguir infinítamente...

No puedes esperar que solo con "dejar" la carpeta que se llama "Windows" y mover todas las demás carpetas a otra partición te vaya a funcionar el SO, un sistema operativo no funciona de esa manera.

Imagínate que pudieras hacer lo que comentas, dime entonces que pasaría si tienes la carpeta "Windows" almacenada en el disco "C", y todas las demás carpetas que no consideras importantes almacenadas en el disco "D", y luego desconectas el disco D por cualquier motivo? > pantallazo azul al instante xD.

PD: -1 por ser de los que confian en "lo mínimo recomendado" por Microsoft '¬¬

Un saludo!
9133  Programación / .NET (C#, VB.NET, ASP) / Re: El Santo Grial de los programadores, como hacer para que se venza al Mes ? en: 30 Abril 2013, 16:43 pm
No soy el creador del código, pero te responderé según lo que estuve testeando.

Acaso usas la fecha del pc donde corre el programa como referencia ?

Si y No, se toma la fecha como referencia para el primer uso, y cuando la fecha cambia (ya séa hacia atrás o hacia delante), cuenta como un día de uso.

Es decir, si tenemos un trial de 7 días y Pasan 5 días, quedan 2 días de uso,
Si el usuario cambia la fecha a -5 días porque se cree muy listo,  ¿al volver a iniciar la aplicación que sucede?,
Que se ha restado 1 día de uso, en lugar de 2 días queda 1 día de uso, porque al cambiar la fecha hacia atrás, el programa ha detectado el cambio de fecha y lo ha contado como un día más de uso.

¿Como puede eludir esta protección un usuario?, fácil, no cambiando la fecha en el sistema, mantener siempre la misma fecha, pero no creo que exista nadie que primero se de cuenta y sepa que para evadir la protección hay que hacer eso, y segundo alguien que séa tán retorcido como para perder 1 minuto cada día para vivir siempre en la misma fecha de su puñetero PC xD.

No sé que tipo de aplicación haces, pero si no está relacionada con la web entonces no te parece demasiado excesivo querer OBLIGAR a disponer de una conexión de internet para utilizar la aplicación?

Un saludo!
9134  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.
9135  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 30 Abril 2013, 13:26 pm
Cambia el theme actual de Windows

Os aconsejo cambiar el theme de esta manera en lugar de usar la función SetWindowTheme porque dicha función no cambia el theme corréctamente (no cambia los colores personalizados).

Código
  1. #Region " Set Aero Theme "
  2.  
  3.    ' [ Set Aero Theme Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Instructions :
  8.    ' Add a reference for "System.ServiceProcess"
  9.    '
  10.    ' Set_Aero_Theme("C:\Windows\Resources\Themes\aero\aero.msstyles")
  11.    ' Set_Aero_Theme("C:\Windows\Resources\Themes\Concave 7\Concave 7.msstyles")
  12.    ' Set_Aero_Theme("C:\Windows\Resources\Themes\Aero\Luna.msstyles", "Metallic", "NormalSize")
  13.  
  14.    Private Function Set_Aero_Theme(ByVal ThemeFile As String, _
  15.                                    Optional ByVal ColorName As String = "NormalColor", _
  16.                                    Optional ByVal SizeName As String = "NormalSize" _
  17.                                   ) As Boolean
  18.        Try
  19.            Using ThemeService As New ServiceProcess.ServiceController("Themes")
  20.                ThemeService.Stop()
  21.                ThemeService.WaitForStatus(1) ' Wait for Stopped
  22.  
  23.                My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ThemeManager", "LoadedBefore", "0", Microsoft.Win32.RegistryValueKind.String)
  24.                My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ThemeManager", "DllName", ThemeFile, Microsoft.Win32.RegistryValueKind.String)
  25.                My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ThemeManager", "ColorName", ColorName, Microsoft.Win32.RegistryValueKind.String)
  26.                My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ThemeManager", "SizeName", SizeName, Microsoft.Win32.RegistryValueKind.String)
  27.  
  28.                ThemeService.Start()
  29.                ThemeService.WaitForStatus(4) ' Wait for Running
  30.            End Using
  31.  
  32.        Catch ex As Exception
  33.            'MsgBox(ex.message)
  34.            Return False
  35.        End Try
  36.  
  37.        Return True
  38.    End Function
  39.  
  40. #End Region



Devuelve información del theme actual

PD: Yo solo he creado la función.

Código
  1. #Region " Get Current Aero Theme "
  2.  
  3.    ' [ Get Current Aero Theme Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples:
  8.    ' MsgBox(Get_Current_Aero_Theme(Theme_Info.Name))
  9.    ' MsgBox(Get_Current_Aero_Theme(Theme_Info.FullPath))
  10.  
  11.    Public Structure ThemeInfo
  12.        Private Declare Unicode Function GetCurrentThemeName _
  13.            Lib "uxtheme.dll" _
  14.        ( _
  15.            ByVal pszThemeFileName As String, _
  16.            ByVal dwMaxNameChars As Int32, _
  17.            ByVal pszColorBuff As String, _
  18.            ByVal cchMaxColorChars As Int32, _
  19.            ByVal pszSizeBuff As String, _
  20.            ByVal cchMaxSizeChars As Int32 _
  21.        ) As Int32
  22.  
  23.        Private Const S_OK As Int32 = &H0
  24.  
  25.        Private m_FileName As String
  26.        Private m_ColorSchemeName As String
  27.        Private m_SizeName As String
  28.  
  29.        Public Property FileName() As String
  30.            Get
  31.                Return m_FileName
  32.            End Get
  33.            Set(ByVal Value As String)
  34.                m_FileName = Value
  35.            End Set
  36.        End Property
  37.  
  38.        Public Property ColorSchemeName() As String
  39.            Get
  40.                Return m_ColorSchemeName
  41.            End Get
  42.            Set(ByVal Value As String)
  43.                m_ColorSchemeName = Value
  44.            End Set
  45.        End Property
  46.  
  47.        Public Property SizeName() As String
  48.            Get
  49.                Return m_SizeName
  50.            End Get
  51.            Set(ByVal Value As String)
  52.                m_SizeName = Value
  53.            End Set
  54.        End Property
  55.  
  56.        Public Overrides Function ToString() As String
  57.            Return _
  58.                "FileName={" & Me.FileName & _
  59.                "} ColorSchemeName={" & Me.ColorSchemeName & _
  60.                "} SizeName={" & Me.SizeName & "}"
  61.        End Function
  62.  
  63.        Public Shared ReadOnly Property CurrentTheme() As ThemeInfo
  64.            Get
  65.                Dim ti As New ThemeInfo()
  66.                Const BufferLength As Int32 = 256
  67.                ti.FileName = Strings.Space(BufferLength)
  68.                ti.ColorSchemeName = ti.FileName
  69.                ti.SizeName = ti.FileName
  70.                If _
  71.                    GetCurrentThemeName( _
  72.                        ti.FileName, _
  73.                        BufferLength, _
  74.                        ti.ColorSchemeName, _
  75.                        BufferLength, _
  76.                        ti.SizeName, _
  77.                        BufferLength _
  78.                    ) = S_OK _
  79.                Then
  80.                    ti.FileName = NullTrim(ti.FileName)
  81.                    ti.ColorSchemeName = NullTrim(ti.ColorSchemeName)
  82.                    ti.SizeName = NullTrim(ti.SizeName)
  83.                    Return ti
  84.                Else
  85.                    Const Message As String = _
  86.                        "An error occured when attempting to get theme info."
  87.                    Throw New Exception(Message)
  88.                End If
  89.            End Get
  90.        End Property
  91.  
  92.        Private Shared Function NullTrim(ByVal Text As String) As String
  93.            Return _
  94.                Strings.Left( _
  95.                    Text, _
  96.                    Strings.InStr(Text, ControlChars.NullChar) - 1 _
  97.                )
  98.        End Function
  99.    End Structure
  100.  
  101.    Public Enum Theme_Info
  102.        Name
  103.        FileName
  104.        FullPath
  105.        ColorScheme
  106.        Size
  107.    End Enum
  108.  
  109.    Private Function Get_Current_Aero_Theme(ByVal Info As Theme_Info) As String
  110.        Select Case Info
  111.            Case Theme_Info.Name : Return ThemeInfo.CurrentTheme.FileName.Split("\").Last.Split(".").First
  112.            Case Theme_Info.FileName : Return ThemeInfo.CurrentTheme.FileName.Split("\").Last
  113.            Case Theme_Info.FullPath : Return ThemeInfo.CurrentTheme.FileName
  114.            Case Theme_Info.ColorScheme : Return ThemeInfo.CurrentTheme.ColorSchemeName
  115.            Case Theme_Info.Size : Return ThemeInfo.CurrentTheme.SizeName
  116.            Case Else : Return Nothing
  117.        End Select
  118.    End Function
  119.  
  120. #End Region



Escribe texto a la CMD desde un proyecto Windowsforms

Código
  1.    Declare Function AttachConsole Lib "kernel32.dll" (ByVal dwProcessId As Int32) As Boolean
  2.    Declare Function FreeConsole Lib "kernel32.dll" () As Boolean
  3.  
  4.    AttachConsole(-1) ' Attach the console
  5.    System.Console.Writeline("I am writing from a WinForm to the console!")
  6.    FreeConsole() ' Desattach the console
  7.  
  8.  




Adjunta una nueva instancia de la CMD a la aplicación.

Código
  1.    Public Declare Function AllocConsole Lib "kernel32.dll" () As Boolean
  2.  
  3.    AllocConsole()
  4.    Console.WriteLine("this is my console!") : Threading.Thread.Sleep(5000)





Detecta si la aplicación se ejecutó desde la consola

Un ejemplo de uso? Pues por ejemplo el que yo le doy, si el usuario ejecuta la aplicación desde la consola entonces muestro una ayuda sobre la sintaxis y etc en la consola, de lo contrario obviamente no muestro nada.

Código
  1. #Region " App Is Launched From CMD? "
  2.  
  3.    ' [ App Is Launched From CMD? Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples:
  8.    ' MsgBox(App_Is_Launched_From_CMD)
  9.    ' If App_Is_Launched_From_CMD() Then Console.WriteLine("Help for this application: ...")
  10.  
  11.    Declare Function AttachConsole Lib "kernel32.dll" (ByVal dwProcessId As Int32) As Boolean
  12.    Declare Function FreeConsole Lib "kernel32.dll" () As Boolean
  13.  
  14.    Private Function App_Is_Launched_From_CMD() As Boolean
  15.        If AttachConsole(-1) Then
  16.            FreeConsole()
  17.            Return True
  18.        Else
  19.            Return False
  20.        End If
  21.    End Function
  22.  
  23. #End Region



Parte un archivo de texto en trozos especificando el tamaño.
PD: El code no es de mi propiedad pero lo he sacado de un código de C# y lo he retocado casi por completo para hacerlo más funcional, así que me doy los créditos.

Código
  1. #Region " Split File "
  2.  
  3.    ' [ Split File Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' MsgBox(Split_File("C:\Test.txt", 10000, , True))
  9.    ' MsgBox(Split_File("C:\Test.txt", 10000, "Splitted"))
  10.  
  11.    Public Function Split_File(ByVal File As String, _
  12.                               ByVal ChunkSize As Long, _
  13.                               Optional ByVal OutputName As String = Nothing, _
  14.                               Optional ByVal Preserve_FileExtension As Boolean = True _
  15.                             ) As Boolean
  16.        Dim Index As Long
  17.        Dim OutputFile As String
  18.        Dim BaseName As String
  19.        Dim StartPosition As Long
  20.        Dim Buffer As Byte() = New Byte() {}
  21.        Dim InputFileStram As System.IO.FileStream
  22.        Dim OutputFileStram As System.IO.FileStream
  23.        Dim BinaryWriter As IO.BinaryWriter
  24.        Dim BinaryReader As IO.BinaryReader
  25.        Dim Fragments As Long
  26.        Dim RemainingBytes As Long
  27.        Dim Progress As Double
  28.        Dim Zeroes As String = ""
  29.  
  30.        Try
  31.            Dim FileInfo As New IO.FileInfo(File)
  32.            Dim Filename As String = FileInfo.FullName
  33.            Dim FileExtension As String = FileInfo.Extension
  34.            Dim outputpath As String = FileInfo.DirectoryName
  35.            Dim FileSize As Long = FileInfo.Length
  36.  
  37.            If OutputName IsNot Nothing Then : BaseName = OutputName
  38.            Else : BaseName = FileInfo.Name.Replace(FileInfo.Extension, "") : End If
  39.  
  40.            If Not IO.File.Exists(Filename) Then
  41.                MsgBox("File " & Filename & " doesn't exist")
  42.                Return False
  43.            End If
  44.  
  45.            If FileSize <= ChunkSize Then
  46.                MsgBox(Filename & " size(" & FileSize & ")  is less than the ChunkSize(" & ChunkSize & ")")
  47.                Return False
  48.            End If
  49.  
  50.            InputFileStram = New IO.FileStream(Filename, IO.FileMode.Open)
  51.            BinaryReader = New IO.BinaryReader(InputFileStram)
  52.            Fragments = Math.Floor(FileSize / ChunkSize)
  53.            For n As Integer = 1 To Fragments.ToString.Length : Zeroes += "0" : Next
  54.            Progress = 100 / Fragments
  55.            RemainingBytes = FileSize - (Fragments * ChunkSize)
  56.            If outputpath = "" Then outputpath = IO.Directory.GetParent(Filename).ToString
  57.            If Not IO.Directory.Exists(outputpath) Then IO.Directory.CreateDirectory(outputpath)
  58.            BinaryReader.BaseStream.Seek(0, IO.SeekOrigin.Begin)
  59.  
  60.            For Index = 1 To Fragments
  61.  
  62.                If Preserve_FileExtension Then : OutputFile = outputpath & "\" & BaseName & "." & Format(Index, Zeroes) & FileExtension
  63.                Else : OutputFile = outputpath & "\" & BaseName & "." & Format(Index, Zeroes)
  64.                End If
  65.  
  66.                ReDim Buffer(ChunkSize - 1)
  67.                BinaryReader.Read(Buffer, 0, ChunkSize)
  68.                StartPosition = BinaryReader.BaseStream.Seek(0, IO.SeekOrigin.Current)
  69.                If IO.File.Exists(OutputFile) Then IO.File.Delete(OutputFile)
  70.                OutputFileStram = New System.IO.FileStream(OutputFile, IO.FileMode.Create)
  71.                BinaryWriter = New IO.BinaryWriter(OutputFileStram)
  72.                BinaryWriter.Write(Buffer)
  73.                OutputFileStram.Flush()
  74.                BinaryWriter.Close()
  75.                OutputFileStram.Close()
  76.            Next
  77.  
  78.            If RemainingBytes > 0 Then
  79.  
  80.                If Preserve_FileExtension Then : OutputFile = outputpath & "\" & BaseName & "." & Format(Index, Zeroes) & FileExtension
  81.                Else : OutputFile = outputpath & "\" & BaseName & "." & Format(Index, Zeroes)
  82.                End If
  83.  
  84.                ReDim Buffer(RemainingBytes - 1)
  85.                BinaryReader.Read(Buffer, 0, RemainingBytes)
  86.                If IO.File.Exists(OutputFile) Then IO.File.Delete(OutputFile)
  87.                OutputFileStram = New System.IO.FileStream(OutputFile, IO.FileMode.Create)
  88.                BinaryWriter = New IO.BinaryWriter(OutputFileStram)
  89.                BinaryWriter.Write(Buffer)
  90.                OutputFileStram.Flush()
  91.                BinaryWriter.Close()
  92.                OutputFileStram.Close()
  93.            End If
  94.  
  95.            InputFileStram.Close()
  96.            BinaryReader.Close()
  97.            Return True
  98.  
  99.        Catch ex As Exception
  100.            MsgBox(ex.Message)
  101.            Return False
  102.        Finally
  103.            BinaryWriter = Nothing
  104.            OutputFileStram = Nothing
  105.            BinaryReader = Nothing
  106.            InputFileStram = Nothing
  107.        End Try
  108.  
  109.    End Function
  110.  
  111. #End Region



Parte un archivo de texto en trozos especificando el número de líneas por archivo.

Código
  1. #Region " Split TextFile By Number Of Lines "
  2.  
  3.    ' [ Split TextFile By Number Of Lines Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' Split_TextFile_By_Number_Of_Lines("C:\Test.txt", 10000)
  9.    ' MsgBox(Split_TextFile_By_Number_Of_Lines("C:\Test.txt", 10))
  10.  
  11.    Private Function Split_TextFile_By_Number_Of_Lines(ByVal TextFile As String, ByVal NumberOfLines As Long) As Boolean
  12.        Try
  13.            Dim FileInfo As New IO.FileInfo(TextFile)
  14.  
  15.            If NumberOfLines > IO.File.ReadAllLines(TextFile).Length Then
  16.                ' MsgBox("Number of lines is greater than total file lines")
  17.                Return False
  18.            End If
  19.  
  20.            Using sr As New System.IO.StreamReader(TextFile)
  21.                Dim fileNumber As Integer = 0
  22.  
  23.                While Not sr.EndOfStream
  24.                    Dim count As Integer = 0
  25.  
  26.                    Using sw As New System.IO.StreamWriter(FileInfo.DirectoryName & "\" & FileInfo.Name.Replace(FileInfo.Extension, " " & System.Threading.Interlocked.Increment(fileNumber) & FileInfo.Extension))
  27.                        sw.AutoFlush = True
  28.                        While Not sr.EndOfStream AndAlso Not System.Threading.Interlocked.Increment(count) > NumberOfLines
  29.                            Application.DoEvents()
  30.                            sw.WriteLine(sr.ReadLine())
  31.                        End While
  32.                    End Using
  33.  
  34.                End While
  35.  
  36.            End Using
  37.            Return True
  38.        Catch ex As Exception
  39.            Throw New Exception(ex.Message)
  40.        End Try
  41.  
  42.    End Function
  43.  
  44. #End Region
9136  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 30 Abril 2013, 13:19 pm
If Debug conditional

Código
  1. #If Debug Then
  2.  
  3. #Else
  4.  
  5. #End If



If Debugger IsAttached conditional
Ejemplo de una condicional de ejecución en Debug
Código
  1.        If Debugger.IsAttached Then
  2.  
  3.        Else
  4.  
  5.        End If



String Format
Ejemplo de un String Format

Código
  1. MsgBox(String.Format("{0}+{1} = {2}", "Uno", "Dos", "Tres"))



Get NT Version

Devuelve la versión NT de Windows

PD: He omitido Windows 3.51 para no complicar el código, pero a quien le importa eso, ¿No?

Código
  1. #Region " Get NT Version "
  2.  
  3.    ' [ Get NT Version Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' MsgBox(Get_NT_Version())
  9.    ' If Get_NT_Version() < 6.0 Then MsgBox("This application only works with an Aero compatible windows version")
  10.  
  11.    Private Function Get_NT_Version() As Double
  12.  
  13.        Dim NT As Double = CDbl(Val(System.Environment.OSVersion.Version.ToString.Substring(0, 3)))
  14.  
  15.        ' INFO:
  16.        ' -----
  17.        ' 3.1 = Windows NT 3.1
  18.        ' 3.5 = Windows NT 3.5
  19.        ' 4.0 = Windows NT 4.0
  20.        ' 5.0 = Windows 2000
  21.        ' 5.1 = Windows XP / Windows Fundamentals for Legacy PCs
  22.        ' 5.2 = Windows XP 64 Bit / Windows server 2003 / Windows server 2003 R2 / Windows home Server
  23.        ' 6.0 = Windows VISTA / Windows server 2008
  24.        ' 6.1 = Windows 7 / Windows server 2008 R2
  25.        ' 6.2 = Windows 8 / Windows 8 Phone / Windows Server 2012
  26.  
  27.        Return NT
  28.  
  29.    End Function
  30.  
#End Region



Extract Icon
Devuelve el icono de un archivo

Código
  1. #Region " Extract Icon "
  2.  
  3.    ' [ Extract Icon Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Me.Icon = Extract_Icon("c:\windows\explorer.exe")
  8.    ' Dim MyIcon as System.Drawing.Icon = Extract_Icon("c:\Test.txt")
  9.  
  10.    Private Function Extract_Icon(ByVal File As String) As System.Drawing.Icon
  11.        If IO.File.Exists(File) Then
  12.            Try : Return System.Drawing.Icon.ExtractAssociatedIcon(File)
  13.            Catch ex As Exception
  14.                'MsgBox(ex.message)
  15.                Return Nothing
  16.            End Try
  17.        Else : Return Nothing
  18.        End If
  19.    End Function
  20.  
  21. #End Region

[OSVersionInfo] - Examples

Ejemplos de uso de OSVersionInfo

Se necesita esta class (o la dll): http://www.codeproject.com/Articles/73000/Getting-Operating-System-Version-Info-Even-for-Win

Código
  1.        MsgBox(OSVersionInfo.Name)
  2.        MsgBox(OSVersionInfo.Edition)
  3.        MsgBox(OSVersionInfo.ServicePack)
  4.        MsgBox(OSVersionInfo.VersionString)
  5.        MsgBox(OSVersionInfo.BuildVersion)
  6.        MsgBox(OSVersionInfo.OSBits.ToString)
  7.        MsgBox(OSVersionInfo.ProcessorBits.ToString)
  8.        MsgBox(OSVersionInfo.ProgramBits.ToString)

9137  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 30 Abril 2013, 13:15 pm
[ListView] Restrict column resizing

Restringe cambiar de tamaño una columna.


Código
  1.    ' [ListView] Restrict column resizing
  2.  
  3.    Private Sub ListView1_ColumnWidthChanging(sender As Object, e As ColumnWidthChangingEventArgs) Handles ListView1.ColumnWidthChanging
  4.        e.Cancel = True
  5.        e.NewWidth = sender.Columns(e.ColumnIndex).Width
  6.    End Sub



Get Non-Client Area Width
Devuelve el tamaño del borde del área NO cliente de la aplicación.

Código
  1. #Region " Get Non-Client Area Width "
  2.  
  3.    ' [ Get Non-Client Area Width Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' MsgBox(Get_NonClientArea_Width(Form1))
  9.    ' Me.Location = New Point((Form1.Location.X + (Form1.Width + Get_NonClientArea_Width(Form1))), Form1.Location.Y)
  10.  
  11.    Private Function Get_NonClientArea_Width(ByVal Form As Form) As Int32
  12.        Return (Form.Width - Form.ClientSize.Width)
  13.    End Function
  14.  
  15. #End Region


Extend Non Client Area
Extiende el área NO cliente al área cliente de la aplicación

Código
  1. #Region " Extend Non Client Area "
  2.  
  3.    ' [ Extend Non Client Area Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' Extend_Non_Client_Area(Me.Handle, 50, 50, -0, 20)
  9.    ' MsgBox(Extend_Non_Client_Area(12345, -1, -1, -1, -1))
  10.  
  11.    <System.Runtime.InteropServices.DllImport("dwmapi.dll")> _
  12.    Private Shared Function DwmExtendFrameIntoClientArea(ByVal handle As IntPtr, ByRef Margins As MARGINS) As Integer
  13.    End Function
  14.  
  15.    <System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)> _
  16.    Public Structure MARGINS
  17.        Public Left As Integer
  18.        Public Right As Integer
  19.        Public Up As Integer
  20.        Public Down As Integer
  21.    End Structure
  22.  
  23.    Private Function Extend_Non_Client_Area(ByVal Window_Handle As IntPtr, _
  24.                                        ByVal Left As Int32, _
  25.                                        ByVal Right As Int32, _
  26.                                        ByVal Up As Int32, _
  27.                                        ByVal Down As Int32) As Boolean
  28.        Try
  29.            Dim Margins As New MARGINS()
  30.            Margins.Left = Left
  31.            Margins.Right = Right
  32.            Margins.Up = Up
  33.            Margins.Down = Down
  34.            DwmExtendFrameIntoClientArea(Window_Handle, Margins)
  35.            Return True
  36.        Catch ex As Exception
  37.            'Return false
  38.            Throw New Exception(ex.Message)
  39.        End Try
  40.  
  41.    End Function
  42.  
  43. #End Region

9138  Programación / .NET (C#, VB.NET, ASP) / Re: Duda usando hilos, se me queda colgado el programa ?? SOLUCIONADO !! en: 30 Abril 2013, 13:10 pm
el problema estaba en que no estaba seteando la variable a TRUE y nunca salia del ciclo while....

Suele pasar xD
9139  Programación / .NET (C#, VB.NET, ASP) / Re: ¿Cómo crear un visualizador de imágenes con botones de siguiente y anterior? en: 30 Abril 2013, 13:08 pm
realmente me parece mas sencillo con list of bitmap y bitmap.fromfile().

Tu eres el que está acostumbrado a trabajar con imágenes :P

Saludos!
9140  Programación / .NET (C#, VB.NET, ASP) / Re: Detener servicios de windows en: 30 Abril 2013, 13:06 pm
Bueno para quien le interese,es que la libreria System.ServiceProcess no funciona en 64 bits,lo he probado en 32 bits y funciona perfectamente. No se si es porque es windows 8 o por que el sistema es 64 bits.

Hola, solo quiero decirte que lo de los 64bits es una tontería, yo uso Windows 7 de 64 bits y como ves te mostré un código funcional.
Lo de que no te funcione porque séa Windows 8 también parece otra tontería, si no fuesen compatible las classes del FW en Windows 8 sería para darle una tremenda hostia a Microsoft, pero eso ya no te lo puedo confirmar.

un saludo!

EDITO: Quizás si pruebas mi aplicación te pueda sacar de dudas si la "System.Serviceprocess" funciona en Win8 de 64 bits o no: http://foro.elhacker.net/net/aporte_aeroswitcher-t389187.0.html;msg1849223#msg1849223
Páginas: 1 ... 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 927 928 929 ... 1232
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines