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

 

 


Tema destacado: Introducción a Git (Primera Parte)


  Mostrar Mensajes
Páginas: 1 ... 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 [565] 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 ... 1236
5641  Programación / Programación C/C++ / Re: ayuda en: 16 Marzo 2015, 19:22 pm
Buenas.

1. Los títulos del mensaje deben ser descriptivos, está prohibido usar títulos cómo "ayudaaa"...

2. Los bloques de código deben ir en su respectiva etiqueta GeShi.

3. Las preguntas sobre C/C++ debes publicarlas en el subforo dedicado a dicho lenguaje.

Lee las reglas del foro y del foro de programación antes de postear.





pero me dice que no he inicializado una variable y no se porque

Aunque no manejo C/C++, el error es self-explanatory (se explica por si mismo), estás utilizando una referencia a un objeto que has declarado, pero no has inicializado, es decir, no le has asignado ningún valor por defecto, es nul,
por ende, la solución debería ser simple, revisa las variables que declaras para localizar aquella variable conflictiva a la que estés intentando acceder sin haberla inicializado primero, por ejemplo:

de:
Código
  1. int numParadas;
a:
Código
  1. int numParadas = 0;
5642  Foros Generales / Dudas Generales / Re: Virtual Box como Sand-box en: 16 Marzo 2015, 18:51 pm
Si una V.M. comparte la red con el equipo huésped entonces cualquier Malware con componente de red (worms) pueden comunicarse e infectar/propagarse al SO huésped.
Si una V.M. comparte discos/carpetas compartidas, entonces la V.M. está exponiendo libremente un canal de almacenamiento al que cualquier Malware puede acceder (para copiarse a si mismo, por ejemplo).

En este video se demuestra cómo una aplicación que se ejecute en el S.O. invitado (V.M.) puede comunicarse con el S.O. huésped (en este ejemplo se hace la finalidad de iniciar un proceso cualquiera cómo es la calculadora de Windows):

http://f.vimeocdn.com/p/flash/moogaloop/6.0.37/moogaloop.swf?clip_id=6595148&color=&fullscreen=1&server=vimeo.com&show_byline=1&show_portrait=0&show_title=1&controller=player2&view=moogaloop_swf&referrer=http%3A%2F%2Fsecurity.stackexchange.com%2Fquestions%2F3056%2Fhow-secure-are-virtual-machines-really-false-sense-of-security&cdn_url=http%3A%2F%2Ff.vimeocdn.com&player_url=player.vimeo.com&moogaloop_type=moogaloop

No soy experto en el diseño de malware pero, obviamente si hacemos estimaciones yo creo que estariamos hablando de un ínfimo porcentaje de desarrolladores de virus que se interesen por y sepan cómo explotar estas vulnerabilidades, ¿quizás un 0,1% de todos los virus conocidos hasta la fecha?, así que realmente yo creo que no es algo preocupante y una V.M. se puede considerar un entorno seguro para el análisis de Malware.

Saludos!
5643  Programación / .NET (C#, VB.NET, ASP) / Re: tomar valores de una cadena numerica y agrupar en variables independientes en: 16 Marzo 2015, 17:37 pm
Arreglo NÚMEROS = (1, 2, 3, 4, 5, 6, 10, 11, 14, 15,  54, 57, 58, 60, 63, 64, 65, 67,)

Esta seria la salida

A=01, 02, 03, 04,
B=05, 06, 10, 11,
C=14, 15,  54, 57
D=58, 60, 63, 64
E= 65, 67, 00  00 <---aca me las arreglo con un pedazo de código tuyo :) para completar

Eso es una simple partición, que no concuerda en absoluto con las colecciones que estás generando en el primer código que mostraste, donde utilizas el operador Mod para filtrar la secuencia y, claro está, da un resultado muy diferente al que has hecho referencia ahora:

Citar
Código
  1.    Dim evensQuery = From num In numbers
  2.                        Where num Mod 2 = 0
  3.                        Select num
  4.  
  5.        Dim ll = From num In numbers
  6.               Where num Mod 2 = 1
  7.               Select num
  8.  
  9.        Dim ll1 = From num In numbers
  10.               Where num Mod 3 = 0
  11.               Select num

¿Entonces?.



En el primer caso, es decir, partir la colección en colecciones de 4 partes (cosa que ya te mostré cómo hacerlo) y rellenar con "ceros" los elementos restantes de la última "parte", es tan sencillo cómo esto:

Código
  1. Public Class Form1
  2.  
  3.    Private Sub Test() Handles MyBase.Shown
  4.  
  5.        Dim values As IEnumerable(Of Integer) =
  6.            {
  7.                1, 2, 3, 4,
  8.                5, 6, 10, 11,
  9.                14, 15, 54, 57,
  10.                58, 60, 63, 64,
  11.                65, 67
  12.            }
  13.  
  14.        Dim splits As IEnumerable(Of IEnumerable(Of Integer)) =
  15.            SplitIntoParts(collection:=values, amount:=4,
  16.                           fillEmpty:=True)
  17.  
  18.        Me.ListBox1.Items.AddRange(splits(0).Cast(Of Object).ToArray)
  19.        Me.ListBox2.Items.AddRange(splits(1).Cast(Of Object).ToArray)
  20.        Me.ListBox3.Items.AddRange(splits(2).Cast(Of Object).ToArray)
  21.  
  22.    End Sub
  23.  
  24.    ''' <remarks>
  25.    ''' *****************************************************************
  26.    ''' Snippet Title: Split Collection Into Parts
  27.    ''' Code's Author: Elektro
  28.    ''' Date Modified: 16-March-2015
  29.    ''' Usage Example:
  30.    ''' Dim mainCol As IEnumerable(Of Integer) = {1, 2, 3, 4, 5, 6, 7, 8, 9}
  31.    ''' Dim splittedCols As IEnumerable(Of IEnumerable(Of Integer)) = SplitColIntoParts(mainCol, amount:=4, fillEmpty:=True)
  32.    ''' splittedCols.ToList.ForEach(Sub(col As IEnumerable(Of Integer))
  33.    '''                                 Debug.WriteLine(String.Join(", ", col))
  34.    '''                             End Sub)
  35.    ''' *****************************************************************
  36.    ''' </remarks>
  37.    ''' <summary>
  38.    ''' Splits an <see cref="IEnumerable(Of T)"/> into the specified amount of elements.
  39.    ''' </summary>
  40.    ''' <typeparam name="T"></typeparam>
  41.    ''' <param name="collection">The collection to split.</param>
  42.    ''' <param name="amount">The target elements amount.</param>
  43.    ''' <param name="fillEmpty">If set to <c>true</c>, generate empty elements to fill the last secuence's part amount.</param>
  44.    ''' <returns>IEnumerable(Of IEnumerable(Of T)).</returns>
  45.    Public Shared Function SplitIntoParts(Of T)(ByVal collection As IEnumerable(Of T),
  46.                                                ByVal amount As Integer,
  47.                                                ByVal fillEmpty As Boolean) As IEnumerable(Of IEnumerable(Of T))
  48.  
  49.        Dim newCol As IEnumerable(Of List(Of T)) =
  50.            (From index As Integer
  51.            In Enumerable.Range(0, CInt(Math.Ceiling(collection.Count() / amount)))
  52.            Select collection.Skip(index * amount).Take(amount).ToList).ToList
  53.  
  54.        If fillEmpty Then
  55.  
  56.            Do Until newCol.Last.Count = amount
  57.                newCol.Last.Add(Nothing)
  58.            Loop
  59.  
  60.        End If
  61.  
  62.        Return newCol
  63.  
  64.    End Function
  65.  
  66. End Class

EDITO:
Una actualización de la función:

Código
  1.    Public Shared Function SplitIntoParts(Of T)(ByVal collection As IEnumerable(Of T),
  2.                                                ByVal amount As Integer,
  3.                                                ByVal fillEmpty As Boolean) As IEnumerable(Of IEnumerable(Of T))
  4.  
  5.        Return From index As Integer In Enumerable.Range(0, CInt(Math.Ceiling(collection.Count() / amount)))
  6.               Select If(Not fillEmpty,
  7.                         collection.Skip(index * amount).Take(amount),
  8.                         If((collection.Count() - (index * amount)) >= amount,
  9.                            collection.Skip(index * amount).Take(amount),
  10.                            collection.Skip(index * amount).Take(amount).
  11.                                                            Concat(From i As Integer
  12.                                                                   In Enumerable.Range(0, amount - (collection.Count() - (index * amount)))
  13.                                                                   Select DirectCast(Nothing, T))))
  14.  
  15.    End Function

Saludos
5644  Programación / .NET (C#, VB.NET, ASP) / Re: Agregar Recurso a un archivo EXE [F1] en: 16 Marzo 2015, 15:54 pm
Imagino que cuando dices que quieres automatizar la tarea pretendes hacerlo desde .Net,
No se si esto te servirá por que no estoy muy seguro de lo si esto es lo que realmente buscas, pero ayer me puse a desarrollar un laaaargo Snippet que quizás te sería de utilidad,
la finalidad del siguiente código es crear y gestionar una tabla de recursos .Net, es decir, un archivo .ResX, que no sería más que un archivo XML donde sus nodos contendrían los datos de los recursos.
El único inconveniente es que al ser un archivo de texto plano, los datos serializados de un recurso binario ocuparían más de lo que ocuparía realmente ese archivo binario (al reconstruirlo), espero que se me entienda, jeje.

Una vez hayas creado el archivo .resx y le hayas añadido los recursos que quieras, solo tendrías que embedir este archivo ResX, al ensamblado.

Te muestro un multi-ejemplo de uso con varios tipos de recursos, aunque está escrito en VB.Net y sino recuerdo mal tú experiencia está basada en C#, pero el uso de este código es sencillo, genérico e intuitivo (o eso pretendí conseguir), no te costaría traducirlo a C#:

Código
  1. Imports System.IO
  2. Imports System.Text
  3.  
  4. Public Class Form1
  5.  
  6.    Private Sub Test() Handles MyBase.Shown
  7.  
  8.        Dim resX As New ResXManager(Path.Combine(Application.StartupPath, "MyResources.resx"))
  9.        With resX
  10.  
  11.            ' Create or replace the ResX file.
  12.            .Create(replace:=True)
  13.  
  14.            ' Add a string resource.
  15.            .AddResource(Of String)("String Resource", "Hello World!", "String Comment")
  16.            ' Add a bitmap resource.
  17.            .AddResource(Of Bitmap)("Bitmap Resource", SystemIcons.Information.ToBitmap, "Bitmap Comment")
  18.            ' Add a binary resource.
  19.            .AddResource(Of Byte())("Binary Resource", File.ReadAllBytes("C:\file.mp3"), "Binary Comment")
  20.  
  21.        End With
  22.  
  23.        ' *******************************************************************************************************
  24.  
  25.        ' Get the string resource.
  26.        Dim stringResource As ResXManager.Resource(Of String) =
  27.            resX.FindResource(Of String)("String Resource", StringComparison.OrdinalIgnoreCase)
  28.  
  29.        ' Get the bitmap resource.
  30.        Dim bitmapResource As ResXManager.Resource(Of Bitmap) =
  31.            resX.FindResource(Of Bitmap)("Bitmap Resource", StringComparison.OrdinalIgnoreCase)
  32.  
  33.        ' Get the binary resource.
  34.        Dim binaryResource As ResXManager.Resource(Of Byte()) =
  35.            resX.FindResource(Of Byte())("Binary Resource", StringComparison.OrdinalIgnoreCase)
  36.  
  37.        ' *******************************************************************************************************
  38.  
  39.        ' Get the string data.
  40.        Dim stringData As String = stringResource.Data
  41.  
  42.        ' Get the bitmap data.
  43.        Dim bitmapData As Bitmap = bitmapResource.Data
  44.  
  45.        ' Get the binary data.
  46.        Dim binaryData As Byte() = binaryResource.Data
  47.  
  48.        ' *******************************************************************************************************
  49.  
  50.        ' Get all the resources at once.
  51.        Dim resources As IEnumerable(Of ResXManager.Resource) = resX.Resources
  52.  
  53.        ' Get all the resources of specific Type at once.
  54.        Dim stringResources As IEnumerable(Of ResXManager.Resource(Of String)) = resX.FindResources(Of String)()
  55.  
  56.        ' *******************************************************************************************************
  57.  
  58.        ' Get all the resource datas at once from Resource collection.
  59.        Dim resourceDatas As IEnumerable(Of Object) =
  60.            From res As ResXManager.Resource In resX.Resources
  61.            Select res.Data
  62.  
  63.        ' Get all the resource datas of specific Type at once from Resource collection.
  64.        Dim stringResourceDatas As IEnumerable(Of String) =
  65.            From res As ResXManager.Resource In resX.Resources
  66.            Where res.Type Is GetType(String)
  67.            Select DirectCast(res.Data, String)
  68.  
  69.        ' *******************************************************************************************************
  70.  
  71.        ' Treat the string resource as you like.
  72.        MessageBox.Show(stringData, String.Empty, MessageBoxButtons.OK, MessageBoxIcon.Information)
  73.  
  74.        ' Treat the bitmap resource as you like.
  75.        Me.Icon = Icon.FromHandle(bitmapData.GetHicon)
  76.  
  77.        ' Treat the binary resource as you like.
  78.        File.WriteAllBytes("C:\new file.mp3", binaryData)
  79.  
  80.        ' *******************************************************************************************************
  81.  
  82.        ' Iterate all the resources.
  83.        For Each res As ResXManager.Resource In resX.Resources
  84.  
  85.            Dim sb As New StringBuilder
  86.  
  87.            sb.AppendLine(String.Format("Name...: {0}", res.Name))
  88.            sb.AppendLine(String.Format("Comment: {0}", res.Comment))
  89.            sb.AppendLine(String.Format("Type...: {0}", res.Type.ToString))
  90.            sb.AppendLine(String.Format("Data...: {0}", res.Data.ToString))
  91.  
  92.            MsgBox(sb.ToString)
  93.        Next
  94.  
  95.        ' Iterate all the resources of specific Type.
  96.        For Each res As ResXManager.Resource(Of String) In resX.FindResources(Of String)()
  97.  
  98.            Dim sb As New StringBuilder
  99.  
  100.            sb.AppendLine(String.Format("Name...: {0}", res.Name))
  101.            sb.AppendLine(String.Format("Comment: {0}", res.Comment))
  102.            sb.AppendLine(String.Format("Type...: {0}", res.Type.ToString))
  103.            sb.AppendLine(String.Format("Data...: {0}", res.Data.ToString))
  104.  
  105.            MsgBox(sb.ToString)
  106.        Next
  107.  
  108.        ' *******************************************************************************************************
  109.  
  110.        ' Remove a resource.
  111.        resX.RemoveResource("Binary Resource")
  112.  
  113.        '  GC.Collect()
  114.  
  115.    End Sub
  116.  
  117. End Class

Este es el código fuente, que obviamente no sería necesario traducirlo a C#, ya que puedes compilarlo a una librería.dll externa o "interna":

Código
  1. ' ***********************************************************************
  2. ' Author   : Elektro
  3. ' Modified : 16-March-2015
  4. ' ***********************************************************************
  5. ' <copyright file="ResXManager.vb" company="Elektro Studios">
  6. '     Copyright (c) Elektro Studios. All rights reserved.
  7. ' </copyright>
  8. ' ***********************************************************************
  9.  
  10. #Region " Option Statements "
  11.  
  12. Option Strict On
  13. Option Explicit On
  14. Option Infer Off
  15.  
  16. #End Region
  17.  
  18. #Region " Usage Examples "
  19.  
  20. #End Region
  21.  
  22. #Region " Imports "
  23.  
  24. Imports System.ComponentModel
  25. Imports System.ComponentModel.Design
  26. Imports System.IO
  27. Imports System.Resources
  28.  
  29. #End Region
  30.  
  31. ''' <summary>
  32. ''' Manages a .Net managed resource file.
  33. ''' </summary>
  34. Public NotInheritable Class ResXManager
  35.  
  36. #Region " Properties "
  37.  
  38.    ''' <summary>
  39.    ''' Gets the .Net managed resource file path.
  40.    ''' </summary>
  41.    ''' <value>The .Net managed resource filepath.</value>
  42.    Public ReadOnly Property FilePath As String
  43.        Get
  44.            Return Me.filePath1
  45.        End Get
  46.    End Property
  47.    ''' <summary>
  48.    ''' The .Net managed resource file path.
  49.    ''' </summary>
  50.    Private ReadOnly filePath1 As String
  51.  
  52.    ''' <summary>
  53.    ''' Gets the resources contained in the .Net managed resource file.
  54.    ''' </summary>
  55.    ''' <value>The resources.</value>
  56.    Public ReadOnly Property Resources As IEnumerable(Of Resource)
  57.        Get
  58.            Return GetResources()
  59.        End Get
  60.    End Property
  61.  
  62. #End Region
  63.  
  64. #Region " Types "
  65.  
  66. #Region " Resource "
  67.  
  68.    ''' <summary>
  69.    ''' Defines a resource of a .Net managed resource file.
  70.    ''' </summary>
  71.    <Serializable>
  72.    Public NotInheritable Class Resource
  73.  
  74. #Region " Properties "
  75.  
  76.        ''' <summary>
  77.        ''' Gets the resource name.
  78.        ''' </summary>
  79.        ''' <value>The resource name.</value>
  80.        Public ReadOnly Property Name As String
  81.            Get
  82.                Return Me.name1
  83.            End Get
  84.        End Property
  85.        Private ReadOnly name1 As String
  86.  
  87.        ''' <summary>
  88.        ''' Gets the resource data.
  89.        ''' </summary>
  90.        ''' <value>The resource data.</value>
  91.        Public ReadOnly Property Data As Object
  92.            Get
  93.                Return Me.data1
  94.            End Get
  95.        End Property
  96.        Private ReadOnly data1 As Object
  97.  
  98.        ''' <summary>
  99.        ''' Gets the resource type.
  100.        ''' </summary>
  101.        ''' <value>The resource type.</value>
  102.        Public ReadOnly Property Type As Type
  103.            Get
  104.                Return Data.GetType
  105.            End Get
  106.        End Property
  107.  
  108.        ''' <summary>
  109.        ''' Gets the resource comment.
  110.        ''' </summary>
  111.        ''' <value>The resource comment.</value>
  112.        Public ReadOnly Property Comment As String
  113.            Get
  114.                Return comment1
  115.            End Get
  116.        End Property
  117.        Private ReadOnly comment1 As String
  118.  
  119.        ''' <summary>
  120.        ''' Represents a <see cref="Resource"/> instance that is <c>Nothing</c>.
  121.        ''' </summary>
  122.        ''' <value><c>Nothing</c></value>
  123.        <EditorBrowsable(EditorBrowsableState.Advanced)>
  124.        Public Shared ReadOnly Property Empty As Resource
  125.            Get
  126.                Return Nothing
  127.            End Get
  128.        End Property
  129.  
  130. #End Region
  131.  
  132. #Region " Constructors "
  133.  
  134.        ''' <summary>
  135.        ''' Initializes a new instance of the <see cref="Resource"/> class.
  136.        ''' </summary>
  137.        ''' <param name="name">The resource name.</param>
  138.        ''' <param name="data">The resource data.</param>
  139.        ''' <param name="comment">The resource comment.</param>
  140.        Public Sub New(ByVal name As String,
  141.                       ByVal data As Object,
  142.                       ByVal comment As String)
  143.  
  144.            Me.name1 = name
  145.            Me.data1 = data
  146.            Me.comment1 = comment
  147.  
  148.        End Sub
  149.  
  150.        ''' <summary>
  151.        ''' Prevents a default instance of the <see cref="Resource"/> class from being created.
  152.        ''' </summary>
  153.        Private Sub New()
  154.        End Sub
  155.  
  156. #End Region
  157.  
  158. #Region " Hidden Methods "
  159.  
  160.        ''' <summary>
  161.        ''' Determines whether the specified System.Object instances are considered equal.
  162.        ''' </summary>
  163.        <EditorBrowsable(EditorBrowsableState.Never)>
  164.        Public Shadows Function Equals(ByVal obj As Object) As Boolean
  165.            Return MyBase.Equals(obj)
  166.        End Function
  167.  
  168.        ''' <summary>
  169.        ''' Serves as a hash function for a particular type.
  170.        ''' </summary>
  171.        <EditorBrowsable(EditorBrowsableState.Never)>
  172.        Public Shadows Function GetHashCode() As Integer
  173.            Return MyBase.GetHashCode
  174.        End Function
  175.  
  176.        ''' <summary>
  177.        ''' Gets the System.Type of the current instance.
  178.        ''' </summary>
  179.        ''' <returns>The exact runtime type of the current instance.</returns>
  180.        <EditorBrowsable(EditorBrowsableState.Never)>
  181.        Public Shadows Function [GetType]() As Type
  182.            Return MyBase.GetType
  183.        End Function
  184.  
  185.        ''' <summary>
  186.        ''' Returns a String that represents the current object.
  187.        ''' </summary>
  188.        <EditorBrowsable(EditorBrowsableState.Never)>
  189.        Public Shadows Function ToString() As String
  190.            Return MyBase.ToString
  191.        End Function
  192.  
  193. #End Region
  194.  
  195.    End Class
  196.  
  197. #End Region
  198.  
  199. #Region " Resource(Of T) "
  200.  
  201.    ''' <summary>
  202.    ''' Defines a resource of a .Net managed resource file.
  203.    ''' </summary>
  204.    <Serializable>
  205.    Public NotInheritable Class Resource(Of T)
  206.  
  207. #Region " Properties "
  208.  
  209.        ''' <summary>
  210.        ''' Gets the resource name.
  211.        ''' </summary>
  212.        ''' <value>The resource name.</value>
  213.        Public ReadOnly Property Name As String
  214.            Get
  215.                Return Me.name1
  216.            End Get
  217.        End Property
  218.        Private ReadOnly name1 As String
  219.  
  220.        ''' <summary>
  221.        ''' Gets the resource data.
  222.        ''' </summary>
  223.        ''' <value>The resource data.</value>
  224.        Public ReadOnly Property Data As T
  225.            Get
  226.                Return Me.data1
  227.            End Get
  228.        End Property
  229.        Private ReadOnly data1 As T
  230.  
  231.        ''' <summary>
  232.        ''' Gets the resource type.
  233.        ''' </summary>
  234.        ''' <value>The resource type.</value>
  235.        Public ReadOnly Property Type As Type
  236.            Get
  237.                Return GetType(T)
  238.            End Get
  239.        End Property
  240.  
  241.        ''' <summary>
  242.        ''' Gets the resource comment.
  243.        ''' </summary>
  244.        ''' <value>The resource comment.</value>
  245.        Public ReadOnly Property Comment As String
  246.            Get
  247.                Return comment1
  248.            End Get
  249.        End Property
  250.        Private ReadOnly comment1 As String
  251.  
  252. #End Region
  253.  
  254. #Region " Constructors "
  255.  
  256.        ''' <summary>
  257.        ''' Initializes a new instance of the <see cref="Resource(Of T)"/> class.
  258.        ''' </summary>
  259.        ''' <param name="name">The resource name.</param>
  260.        ''' <param name="data">The resource data.</param>
  261.        ''' <param name="comment">The resource comment.</param>
  262.        Public Sub New(ByVal name As String,
  263.                       ByVal data As T,
  264.                       ByVal comment As String)
  265.  
  266.            Me.name1 = name
  267.            Me.data1 = data
  268.            Me.comment1 = comment
  269.  
  270.        End Sub
  271.  
  272.        ''' <summary>
  273.        ''' Prevents a default instance of the <see cref="Resource(Of T)"/> class from being created.
  274.        ''' </summary>
  275.        Private Sub New()
  276.        End Sub
  277.  
  278. #End Region
  279.  
  280. #Region " Hidden Methods "
  281.  
  282.        ''' <summary>
  283.        ''' Determines whether the specified System.Object instances are considered equal.
  284.        ''' </summary>
  285.        <EditorBrowsable(EditorBrowsableState.Never)>
  286.        Public Shadows Function Equals(ByVal obj As Object) As Boolean
  287.            Return MyBase.Equals(obj)
  288.        End Function
  289.  
  290.        ''' <summary>
  291.        ''' Serves as a hash function for a particular type.
  292.        ''' </summary>
  293.        <EditorBrowsable(EditorBrowsableState.Never)>
  294.        Public Shadows Function GetHashCode() As Integer
  295.            Return MyBase.GetHashCode
  296.        End Function
  297.  
  298.        ''' <summary>
  299.        ''' Gets the System.Type of the current instance.
  300.        ''' </summary>
  301.        ''' <returns>The exact runtime type of the current instance.</returns>
  302.        <EditorBrowsable(EditorBrowsableState.Never)>
  303.        Public Shadows Function [GetType]() As Type
  304.            Return MyBase.GetType
  305.        End Function
  306.  
  307.        ''' <summary>
  308.        ''' Returns a String that represents the current object.
  309.        ''' </summary>
  310.        <EditorBrowsable(EditorBrowsableState.Never)>
  311.        Public Shadows Function ToString() As String
  312.            Return MyBase.ToString
  313.        End Function
  314.  
  315. #End Region
  316.  
  317.    End Class
  318.  
  319. #End Region
  320.  
  321. #End Region
  322.  
  323. #Region " Constructors "
  324.  
  325.    ''' <summary>
  326.    ''' Initializes a new instance of the <see cref="ResXManager"/> class.
  327.    ''' </summary>
  328.    ''' <param name="resxFilePath">The .Net managed resource filepath.</param>
  329.    Public Sub New(ByVal resxFilePath As String)
  330.        Me.filePath1 = resxFilePath
  331.    End Sub
  332.  
  333.    ''' <summary>
  334.    ''' Prevents a default instance of the <see cref="ResXManager"/> class from being created.
  335.    ''' </summary>
  336.    Private Sub New()
  337.    End Sub
  338.  
  339. #End Region
  340.  
  341. #Region " Public Methods "
  342.  
  343.    ''' <summary>
  344.    ''' Creates the .Net managed resource file.
  345.    ''' </summary>
  346.    ''' <param name="replace">if set to <c>true</c>, replaces any existent file.</param>
  347.    ''' <exception cref="System.Exception"></exception>
  348.    Public Sub Create(Optional ByVal replace As Boolean = False)
  349.  
  350.        If Not replace AndAlso File.Exists(Me.filePath1) Then
  351.            Throw New Exception(String.Format("Resource file already exists: {0}", Me.filePath1))
  352.            Exit Sub
  353.        End If
  354.  
  355.        Dim resXWritter As ResXResourceWriter = Nothing
  356.        Try
  357.            resXWritter = New ResXResourceWriter(Me.filePath1)
  358.            Using resXWritter
  359.                resXWritter.Generate()
  360.            End Using
  361.  
  362.        Catch ex As Exception
  363.            Throw
  364.  
  365.        Finally
  366.            If resXWritter IsNot Nothing Then
  367.                resXWritter.Close()
  368.            End If
  369.  
  370.        End Try
  371.  
  372.    End Sub
  373.  
  374.    ''' <summary>
  375.    ''' Adds a resource into the .Net managed resource file.
  376.    ''' </summary>
  377.    ''' <param name="name">The resource name.</param>
  378.    ''' <param name="data">The resource data.</param>
  379.    ''' <param name="comment">The resource comment.</param>
  380.    ''' <exception cref="System.IO.FileNotFoundException">Resource file not found.</exception>
  381.    ''' <exception cref="System.ArgumentException">A resource with the same name already exists in the table.;name</exception>
  382.    Public Sub AddResource(ByVal name As String,
  383.                           ByVal data As Object,
  384.                           Optional ByVal comment As String = Nothing)
  385.  
  386.        Me.AddResource(replace:=False, name:=name, data:=data, comment:=comment)
  387.  
  388.    End Sub
  389.  
  390.    ''' <summary>
  391.    ''' Adds a specified resource of the specified type into the .Net managed resource file.
  392.    ''' </summary>
  393.    ''' <typeparam name="T"></typeparam>
  394.    ''' <param name="name">The resource name.</param>
  395.    ''' <param name="data">The resource data.</param>
  396.    ''' <param name="comment">The resource comment.</param>
  397.    ''' <exception cref="System.IO.FileNotFoundException">Resource file not found.</exception>
  398.    ''' <exception cref="System.ArgumentException">A resource with the same name already exists in the table.;name</exception>
  399.    Public Sub AddResource(Of T)(ByVal name As String,
  400.                                 ByVal data As T,
  401.                                 Optional ByVal comment As String = Nothing)
  402.  
  403.        Me.AddResource(replace:=False, name:=name, data:=data, comment:=comment)
  404.  
  405.    End Sub
  406.  
  407.    ''' <summary>
  408.    ''' Replaces a resource by the specified name inside the .Net managed resource file.
  409.    ''' </summary>
  410.    ''' <param name="name">The resource name.</param>
  411.    ''' <param name="data">The resource data.</param>
  412.    ''' <param name="comment">The resource comment.</param>
  413.    ''' <exception cref="System.IO.FileNotFoundException">Resource file not found.</exception>
  414.    ''' <exception cref="System.ArgumentException">A resource with the same name already exists in the table.;name</exception>
  415.    Public Sub ReplaceResource(ByVal name As String,
  416.                               ByVal data As Object,
  417.                               Optional ByVal comment As String = Nothing)
  418.  
  419.        Me.AddResource(replace:=True, name:=name, data:=data, comment:=comment)
  420.  
  421.    End Sub
  422.  
  423.    ''' <summary>
  424.    ''' Replaces a resource by the specified name of the specified type inside the .Net managed resource file.
  425.    ''' </summary>
  426.    ''' <typeparam name="T"></typeparam>
  427.    ''' <param name="name">The resource name.</param>
  428.    ''' <param name="data">The resource data.</param>
  429.    ''' <param name="comment">The resource comment.</param>
  430.    ''' <exception cref="System.IO.FileNotFoundException">Resource file not found.</exception>
  431.    ''' <exception cref="System.ArgumentException">A resource with the same name already exists in the table.;name</exception>
  432.    Public Sub ReplaceResource(Of T)(ByVal name As String,
  433.                                     ByVal data As T,
  434.                                     Optional ByVal comment As String = Nothing)
  435.  
  436.        Me.AddResource(replace:=True, name:=name, data:=data, comment:=comment)
  437.  
  438.    End Sub
  439.  
  440.    ''' <summary>
  441.    ''' Finds a resource by the specified name of specified type inside the .Net managed resource file.
  442.    ''' </summary>
  443.    ''' <typeparam name="T"></typeparam>
  444.    ''' <param name="name">The resource name.</param>
  445.    ''' <param name="stringComparison">The <see cref="StringComparison"/> to compare the resource name.</param>
  446.    ''' <returns>The resource.</returns>
  447.    ''' <exception cref="System.IO.FileNotFoundException">Resource file not found.</exception>
  448.    ''' <exception cref="System.ArgumentException">Resource with the specified name is not found.;name</exception>
  449.    ''' <exception cref="System.ArgumentException">The specified Type differs from the resource Type.;T</exception>
  450.    Public Function FindResource(Of T)(ByVal name As String,
  451.                                       Optional ByVal stringComparison As StringComparison =
  452.                                                      StringComparison.OrdinalIgnoreCase) As Resource(Of T)
  453.  
  454.        If Not File.Exists(Me.filePath1) Then
  455.            Throw New FileNotFoundException("Resource file not found.", Me.filePath1)
  456.            Exit Function
  457.        End If
  458.  
  459.        ' Read the ResX file.
  460.        Dim resX As ResXResourceReader = Nothing
  461.        Dim res As Resource(Of T) = Nothing
  462.        Try
  463.            resX = New ResXResourceReader(Me.filePath1) With {.UseResXDataNodes = True}
  464.            Using resX
  465.  
  466.                For Each entry As DictionaryEntry In resX
  467.  
  468.                    If entry.Key.ToString.Equals(name, stringComparison) Then
  469.  
  470.                        Dim node As ResXDataNode = CType(entry.Value, ResXDataNode)
  471.  
  472.                        res = New Resource(Of T)(name:=node.Name,
  473.                                                 data:=DirectCast(node.GetValue(DirectCast(Nothing, ITypeResolutionService)), T),
  474.                                                 comment:=node.Comment)
  475.                        Exit For
  476.  
  477.                    End If
  478.  
  479.                Next entry
  480.  
  481.            End Using ' resX
  482.  
  483.            Return res
  484.  
  485.        Catch ex As Exception
  486.            Throw
  487.  
  488.        Finally
  489.            If resX IsNot Nothing Then
  490.                resX.Close()
  491.            End If
  492.  
  493.        End Try
  494.  
  495.    End Function
  496.  
  497.    ''' <summary>
  498.    ''' Finds a resource by the specified name inside the .Net managed resource file.
  499.    ''' </summary>
  500.    ''' <param name="name">The resource name.</param>
  501.    ''' <param name="stringComparison">The <see cref="StringComparison"/> to compare the resource name.</param>
  502.    ''' <returns>The resource.</returns>
  503.    ''' <exception cref="System.IO.FileNotFoundException">Resource file not found.</exception>
  504.    ''' <exception cref="System.ArgumentException">Resource with the specified name is not found.;name</exception>
  505.    ''' <exception cref="System.ArgumentException">The specified Type differs from the resource Type.;T</exception>
  506.    Public Function FindResource(ByVal name As String,
  507.                                 Optional ByVal stringComparison As StringComparison =
  508.                                                StringComparison.OrdinalIgnoreCase) As Resource
  509.  
  510.        If Not File.Exists(Me.filePath1) Then
  511.            Throw New FileNotFoundException("Resource file not found.", Me.filePath1)
  512.            Exit Function
  513.        End If
  514.  
  515.        ' Read the ResX file.
  516.        Dim resX As ResXResourceReader = Nothing
  517.        Dim res As Resource = Nothing
  518.        Try
  519.            resX = New ResXResourceReader(Me.filePath1) With {.UseResXDataNodes = True}
  520.            Using resX
  521.  
  522.                For Each entry As DictionaryEntry In resX
  523.  
  524.                    If entry.Key.ToString.Equals(name, stringComparison) Then
  525.  
  526.                        Dim node As ResXDataNode = CType(entry.Value, ResXDataNode)
  527.  
  528.                        res = New Resource(name:=node.Name,
  529.                                           data:=node.GetValue(DirectCast(Nothing, ITypeResolutionService)),
  530.                                           comment:=node.Comment)
  531.                        Exit For
  532.  
  533.                    End If
  534.  
  535.                Next entry
  536.  
  537.            End Using ' resX
  538.  
  539.            Return res
  540.  
  541.        Catch ex As Exception
  542.            Throw
  543.  
  544.        Finally
  545.            If resX IsNot Nothing Then
  546.                resX.Close()
  547.            End If
  548.  
  549.        End Try
  550.  
  551.    End Function
  552.  
  553.    ''' <summary>
  554.    ''' Finds the resources of the specified type inside the .Net managed resource file.
  555.    ''' </summary>
  556.    ''' <typeparam name="T"></typeparam>
  557.    ''' <returns>The resource.</returns>
  558.    ''' <exception cref="System.IO.FileNotFoundException">Resource file not found.</exception>
  559.    ''' <exception cref="System.ArgumentException">Resource with the specified name is not found.;name</exception>
  560.    ''' <exception cref="System.ArgumentException">The specified Type differs from the resource Type.;T</exception>
  561.    Public Iterator Function FindResources(Of T)() As IEnumerable(Of Resource(Of T))
  562.  
  563.        If Not File.Exists(Me.filePath1) Then
  564.            Throw New FileNotFoundException("Resource file not found.", Me.filePath1)
  565.            Exit Function
  566.        End If
  567.  
  568.        ' Read the ResX file.
  569.        Dim resX As ResXResourceReader = Nothing
  570.        Try
  571.            resX = New ResXResourceReader(Me.filePath1) With {.UseResXDataNodes = True}
  572.            Using resX
  573.  
  574.                For Each entry As DictionaryEntry In resX
  575.  
  576.                    Dim node As ResXDataNode = CType(entry.Value, ResXDataNode)
  577.  
  578.                    If node.GetValue(DirectCast(Nothing, ITypeResolutionService)).GetType Is GetType(T) Then
  579.  
  580.                        Yield New Resource(Of T)(name:=node.Name,
  581.                                           data:=DirectCast(node.GetValue(DirectCast(Nothing, ITypeResolutionService)), T),
  582.                                           comment:=node.Comment)
  583.  
  584.                    End If
  585.  
  586.                Next entry
  587.  
  588.            End Using ' resX
  589.  
  590.        Catch ex As Exception
  591.            Throw
  592.  
  593.        Finally
  594.            If resX IsNot Nothing Then
  595.                resX.Close()
  596.            End If
  597.  
  598.        End Try
  599.  
  600.    End Function
  601.  
  602.    ''' <summary>
  603.    ''' Removes a resource by the specified name from the .Net managed resource file.
  604.    ''' </summary>
  605.    ''' <param name="name">The resource name.</param>
  606.    ''' <param name="stringComparison">The <see cref="StringComparison"/> to compare the resource name.</param>
  607.    ''' <exception cref="System.IO.FileNotFoundException">Resource file not found.</exception>
  608.    ''' <exception cref="System.ArgumentException">Any resource found matching the specified name.;name</exception>
  609.    Public Sub RemoveResource(ByVal name As String,
  610.                              Optional ByVal stringComparison As StringComparison =
  611.                                             StringComparison.OrdinalIgnoreCase)
  612.  
  613.        If Not File.Exists(Me.filePath1) Then
  614.            Throw New FileNotFoundException("Resource file not found.", Me.filePath1)
  615.            Exit Sub
  616.        End If
  617.  
  618.        If Me.FindResource(name, stringComparison) Is Nothing Then
  619.            Throw New ArgumentException("Any resource found matching the specified name.", "name")
  620.            Exit Sub
  621.        End If
  622.  
  623.        Dim resources As New List(Of ResXDataNode)
  624.        Dim resX As ResXResourceReader = Nothing
  625.        Dim resXWritter As ResXResourceWriter = Nothing
  626.  
  627.        Try
  628.            resX = New ResXResourceReader(Me.filePath1) With {.UseResXDataNodes = True}
  629.            Using resX
  630.  
  631.                For Each entry As DictionaryEntry In resX
  632.  
  633.                    If Not entry.Key.ToString.Equals(name, stringComparison) Then
  634.  
  635.                        Dim node As ResXDataNode = CType(entry.Value, ResXDataNode)
  636.                        resources.Add(New ResXDataNode(name:=node.Name, value:=node.GetValue(DirectCast(Nothing, ITypeResolutionService))) With {.Comment = node.Comment})
  637.  
  638.                    End If
  639.  
  640.                Next entry
  641.  
  642.            End Using
  643.  
  644.            ' Add the resource in the ResX file.
  645.            ' Note: This will replace the current ResX file.
  646.            resXWritter = New ResXResourceWriter(Me.filePath1)
  647.            Using resXWritter
  648.  
  649.                ' Add the retrieved resources into the ResX file.
  650.                If resources IsNot Nothing Then
  651.                    For Each resourceItem As ResXDataNode In resources
  652.                        resXWritter.AddResource(resourceItem)
  653.                    Next resourceItem
  654.                End If
  655.  
  656.                resXWritter.Generate()
  657.  
  658.            End Using ' resXWritter
  659.  
  660.        Catch ex As Exception
  661.            Throw
  662.  
  663.        Finally
  664.            If resX IsNot Nothing Then
  665.                resX.Close()
  666.            End If
  667.  
  668.            If resXWritter IsNot Nothing Then
  669.                resXWritter.Close()
  670.            End If
  671.  
  672.            resources.Clear()
  673.  
  674.        End Try
  675.  
  676.    End Sub
  677.  
  678. #End Region
  679.  
  680. #Region " Private Methods "
  681.  
  682.    ''' <summary>
  683.    ''' Adds or replaces a resource into the .Net managed resource file.
  684.    ''' </summary>
  685.    ''' <param name="replace">if set to <c>true</c>, the resource will be replaced.</param>
  686.    ''' <param name="name">The resource name.</param>
  687.    ''' <param name="data">The resource data.</param>
  688.    ''' <param name="comment">The resource comment.</param>
  689.    ''' <exception cref="System.IO.FileNotFoundException">Resource file not found.</exception>
  690.    ''' <exception cref="System.ArgumentException">A resource with the same name already exists in the table.;name</exception>
  691.    Private Sub AddResource(ByVal replace As Boolean,
  692.                            ByVal name As String,
  693.                            ByVal data As Object,
  694.                            ByVal comment As String)
  695.  
  696.        If Not File.Exists(Me.filePath1) Then
  697.            Throw New FileNotFoundException("Resource file not found.", Me.filePath1)
  698.            Exit Sub
  699.        End If
  700.  
  701.        Dim resources As New List(Of ResXDataNode)
  702.        Dim resX As ResXResourceReader = Nothing
  703.        Dim resXWritter As ResXResourceWriter = Nothing
  704.  
  705.        Try
  706.            resX = New ResXResourceReader(Me.filePath1) With {.UseResXDataNodes = True}
  707.            Using resX
  708.  
  709.                For Each entry As DictionaryEntry In resX
  710.  
  711.                    If Not replace AndAlso entry.Key.ToString.Equals(name, StringComparison.OrdinalIgnoreCase) Then
  712.                        Throw New ArgumentException("A resource with the same name already exists in the table.", "name")
  713.  
  714.                    Else
  715.                        Dim node As ResXDataNode = CType(entry.Value, ResXDataNode)
  716.                        resources.Add(New ResXDataNode(name:=node.Name, value:=node.GetValue(DirectCast(Nothing, ITypeResolutionService))) With {.Comment = node.Comment})
  717.  
  718.                    End If
  719.  
  720.                Next entry
  721.  
  722.            End Using
  723.  
  724.            ' Add the resource in the ResX file.
  725.            ' Note: This will replace the current ResX file.
  726.            resXWritter = New ResXResourceWriter(Me.filePath1)
  727.            Using resXWritter
  728.  
  729.                ' Add the retrieved resources into the ResX file.
  730.                If resources IsNot Nothing Then
  731.                    For Each resourceItem As ResXDataNode In resources
  732.                        resXWritter.AddResource(resourceItem)
  733.                    Next resourceItem
  734.                End If
  735.  
  736.                ' Add the specified resource into the ResX file.
  737.                resXWritter.AddResource(New ResXDataNode(name, data) With {.Name = name, .Comment = comment})
  738.                resXWritter.Generate()
  739.  
  740.            End Using ' resXWritter
  741.  
  742.        Catch ex As Exception
  743.            Throw
  744.  
  745.        Finally
  746.            If resX IsNot Nothing Then
  747.                resX.Close()
  748.            End If
  749.  
  750.            If resXWritter IsNot Nothing Then
  751.                resXWritter.Close()
  752.            End If
  753.  
  754.            resources.Clear()
  755.  
  756.        End Try
  757.  
  758.    End Sub
  759.  
  760.    ''' <summary>
  761.    ''' Gets all the resources contained in the .Net managed resource file.
  762.    ''' </summary>
  763.    ''' <returns>IEnumerable(Of Resource).</returns>
  764.    Private Iterator Function GetResources() As IEnumerable(Of Resource)
  765.  
  766.        ' Read the ResX file.
  767.        Using resX As New Resources.ResXResourceReader(Me.filePath1) With {.UseResXDataNodes = True}
  768.  
  769.            For Each entry As DictionaryEntry In resX
  770.  
  771.                Dim node As ResXDataNode = CType(entry.Value, ResXDataNode)
  772.  
  773.                Yield New Resource(name:=node.Name,
  774.                                   data:=node.GetValue(DirectCast(Nothing, ITypeResolutionService)),
  775.                                   comment:=node.Comment)
  776.  
  777.            Next entry
  778.  
  779.        End Using ' resX
  780.  
  781.    End Function
  782.  
  783. #End Region
  784.  
  785. #Region " Hidden Methods "
  786.  
  787.    ''' <summary>
  788.    ''' Determines whether the specified System.Object instances are considered equal.
  789.    ''' </summary>
  790.    <EditorBrowsable(EditorBrowsableState.Never)>
  791.    Public Shadows Function Equals(ByVal obj As Object) As Boolean
  792.        Return MyBase.Equals(obj)
  793.    End Function
  794.  
  795.    ''' <summary>
  796.    ''' Serves as a hash function for a particular type.
  797.    ''' </summary>
  798.    <EditorBrowsable(EditorBrowsableState.Never)>
  799.    Public Shadows Function GetHashCode() As Integer
  800.        Return MyBase.GetHashCode
  801.    End Function
  802.  
  803.    ''' <summary>
  804.    ''' Gets the System.Type of the current instance.
  805.    ''' </summary>
  806.    ''' <returns>The exact runtime type of the current instance.</returns>
  807.    <EditorBrowsable(EditorBrowsableState.Never)>
  808.    Public Shadows Function [GetType]() As Type
  809.        Return MyBase.GetType
  810.    End Function
  811.  
  812.    ''' <summary>
  813.    ''' Returns a String that represents the current object.
  814.    ''' </summary>
  815.    <EditorBrowsable(EditorBrowsableState.Never)>
  816.    Public Shadows Function ToString() As String
  817.        Return MyBase.ToString
  818.    End Function
  819.  
  820. #End Region
  821.  
  822. End Class

Saludos!
5645  Programación / .NET (C#, VB.NET, ASP) / Re: tomar valores de una cadena numerica y agrupar en variables independientes en: 16 Marzo 2015, 15:33 pm
a medida que alargo los números estos se quedan cortos ;(

¿Qué?.

Compila el código que has mostrado, mira el resultado que da (2,4,6,10 | 1,3,5,11 | 3,6,15,54), y explica que resultado sería el que esperas obtener.

Saludos
5646  Sistemas Operativos / Windows / Re: Abrir archivo portable al ejecutar windows en: 16 Marzo 2015, 15:04 pm
Hay varias formas, creando una tarea del sistema específica para iniciar una aplicación al iniciar sesión, añadir un valor a la clave de registro que administra las aplicaciones que se inician al iniciar sesión, o añadiendo aplicaciones/accesos directos en el directorio Startup, que eso parece ser lo que quieres:

"C:\Users\Nombre\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"

PD: Si quieres conocer más detalles sobre las otras alternativas, haz una búsqueda en Google, la información abunda.

Saludos
5647  Programación / Programación General / MOVIDO: estoy empezando con C y tengo un problemilla, ayuda xD en: 16 Marzo 2015, 03:51 am
El tema ha sido movido a Programación C/C++.

http://foro.elhacker.net/index.php?topic=431851.0
5648  Programación / .NET (C#, VB.NET, ASP) / Re: Agregar Recurso a un archivo EXE [F1] en: 15 Marzo 2015, 18:33 pm
Busco automatizar el proceso, es decir, crearme una aplicación que agregue recursos a un EXE .NET

Voy a averiguar sobre ILMerge, si tienes algun info?.

Puedes recurrir a la ayuda integrada en la aplicación (por linea de comandos), o googlear la documentación de los parámetros de la aplicación en MSDN o Technet.
http://research.microsoft.com/en-us/people/mbarnett/ilmerge.aspx
(fíjate en el hyperlink del .doc que contiene la documentación)

Pero hay un detalle importante, se me olvidó que solo podrás "unir" ensamblados .Net, esa es su limitación, es decir, no podrás interactuar con otro tipo de archivos como un binario de C/C++ que tnega código nativo, o un archivo de texto plano, etc, o al menos eso tengo entendido por lo que especifica Microsoft, pero lo cierto es que nunca lo intenté.

Saludos
5649  Foros Generales / Dudas Generales / Re: Quiero ser moderador! en: 15 Marzo 2015, 03:37 am
Buenas

Hola, quisiera ser moderador del foro, cuales son los requisitos??  :rolleyes:

Si realmente quieres tener una mínima posibilidad de que alguien (cualquier persona) se tome en serio tu pregunta, entonces podrías empezar por reemplazar esa imagen gigantesca, desagradable e irrelevante, para expresar y dar a conocer algo sobre tí, empezando por las motivaciones que te hayan llevado a formular esa pregunta, así cómo tu temática favorita del foro (a la que aspires a moderar), tus conocimientos, etc, etc, etc. Lo que sea menos imágenes de South-Park :¬¬.

PD: Lo digo para ayudar...

Saludos!
5650  Programación / .NET (C#, VB.NET, ASP) / Re: Agregar Recurso a un archivo EXE [F1] en: 15 Marzo 2015, 02:43 am
Si tienes el source del proyecto entonces puedes embedir directamente cualquier archivo a la compilación del exe desde la IDE:



Si no tienes el source, entonces puedes utilizar la herramienta command-line ILMerge de Microsoft, o la GUI ILMerge-GUI, o herramientas de pago cómo .Net Shrink.

Saludos
Páginas: 1 ... 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 [565] 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 ... 1236
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines