Proyecto AjpdSoft
Principal
· Inicio
· Buscar
· Contactar
· Descargas
· Enciclopedia
· Estadísticas
· Eventos
· Foros
· Manuales, Artículos
· Nuestra historia
· Quiénes somos
· Recomiéndanos
· Temas
· Top 10
· Trucos Delphi, PHP, Java, Visual Studio
· Tu cuenta
Descargas

Últimas Descargas
· Ejemplo acceso nativo a SQLite con ADO.Net en C# .Net

· AjpdSoft Acceso MySQL Android

· AjpdSoft Acceso SQLite C# ADO.NET

· AjpdSoft Acceso MySQL con ADO.NET en C#

· AjpdSoft Gestión Integral código fuente Delphi

· AjpdSoft Indexar Texto PDF C# iTextSharp

· AjpdSoft Capturar Pantalla C#

· AjpdSoft Gestión de Transportes Ficheros instalación manual

· AjpdSoft Separar Páginas PDF código fuente C# C Sharp .Net

· AjpdSoft Convertir Texto a PDF código fuente VB.Net

· AjpdSoft Generador y Lector códigos QR VB.Net

· AjpdSoft Socket VB.Net

· AjpdSoft Acceso nativo MySQL enlazado VB.Net

· AjpdSoft Acceso nativo MySQL VB.Net

· AjpdSoft Envío SMS puerto serie módem GSM VB.Net


Lo más descargado
· AjpdSoft Registro de OCX y DLL Código Fuente Delphi

· AjpdSoft Generador de códigos de barras

· AjpdSoft Conversor Hexadecimal, Decimal, Texto - Código Fuente Delphi

· Borland Database Desktop 7.0

· AjpdSoft Aviso cambio IP pública

· AjpdSoft Inventario PCs

· AjpdSoft Administración Bases de Datos Código Fuente Delphi

· AjpdSoft Facturación Código Fuente Delphi

· AjpdSoft Puerto Paralelo Código Fuente Delphi

· AjpdSoft Inventario PCs Código Fuente Delphi

· Cómo trabajar con tablas Paradox en red

· Cómo compilar un fichero MDB Base de Datos Access

· AjpdSoft Aviso cambio IP pública Código Fuente Delphi

· AjpdSoft Conexión BD Visual Basic .Net

· AjpdSoft Agenda Código Fuente Delphi

Términos enciclopedias
Últimos
· CSRF
Enc.: Informática

· SIG
Enc.: Informática

· Ruby
Enc.: Informática

· DATEDIFF (fecha1, fecha2)
Enc.: Funciones MySQL

· DaysBetween (fecha1, fecha2)
Enc.: Funciones Delphi

· Telnet
Enc.: Informática

· OSI
Enc.: Informática

· LTO
Enc.: Informática

· DoS, DDoS
Enc.: Informática

· NVRAM
Enc.: Informática

· DATE_SUB (date, INTERVAL)
Enc.: Funciones MySQL

· CURDATE ()
Enc.: Funciones MySQL

· DES
Enc.: Informática

· RSA
Enc.: Informática

· VMFS
Enc.: Informática


Lo más visitado

· Attrib
Enc.: Comandos Windows XP/Windows 2000/2003 (consola MS-DOS)

· At
Enc.: Comandos Windows XP/Windows 2000/2003 (consola MS-DOS)

· Arp
Enc.: Comandos Windows XP/Windows 2000/2003 (consola MS-DOS)

· URL
Enc.: Informática

· net use unidad: \\nombrepc\recursocompartido
Enc.: Comandos Windows XP/Windows 2000/2003 (consola MS-DOS)

· bootcfg addsw
Enc.: Comandos Windows XP/Windows 2000/2003 (consola MS-DOS)

· MSKSrvr.exe
Enc.: Procesos en memoria

· ODBC
Enc.: Informática

· Mozilla Firefox
Enc.: Programas/Software

· xcopy
Enc.: Comandos Windows XP/Windows 2000/2003 (consola MS-DOS)

· Call
Enc.: Comandos Windows XP/Windows 2000/2003 (consola MS-DOS)

· Gpupdate
Enc.: Comandos Windows XP/Windows 2000/2003 (consola MS-DOS)

· netstat -n
Enc.: Comandos Windows XP/Windows 2000/2003 (consola MS-DOS)

· Assoc
Enc.: Comandos Windows XP/Windows 2000/2003 (consola MS-DOS)

· net view
Enc.: Comandos Windows XP/Windows 2000/2003 (consola MS-DOS)
Eventos
Junio

DLMMJVS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Consejos
Lenguajes
Selecciona Idioma de la Interfaz:

Webs recomendadas
Orasite.com



Coloca tu web aquí
Language english
English
Funciones para leer y escribir en ficheros INI VB.Net
Lenguaje de programación Visual Basic .Net

Mostramos varias funciones para leer y escribir en ficheros de configuración INI: leer boolean, string, integer, escribir boolean, string, integer.

Hemos incluido dichas funciones en una clase, de forma que copiando esta clase y agregándola a un proyecto Visual Basic .Net podremos usarlas desde cualquier parte de nuestra aplicación.

Para la lectura y escritura en ficheros INI con VB.Net usamos el API de Windows, las funciones: GetPrivateProfileString, WritePrivateProfileString, GetPrivateProfileInt, FlushPrivateProfileString.


Public Class FicherosINI
    ' Funciones del API de Windows para ficheros INI
    Private Declare Ansi Function GetPrivateProfileString _
      Lib "kernel32.dll" Alias "GetPrivateProfileStringA" _
      (ByVal lpApplicationName As String, _
      ByVal lpKeyName As String, ByVal lpDefault As String, _
      ByVal lpReturnedString As System.Text.StringBuilder, _
      ByVal nSize As Integer, ByVal lpFileName As String) _
      As Integer

    Private Declare Ansi Function WritePrivateProfileString _
      Lib "kernel32.dll" Alias "WritePrivateProfileStringA" _
      (ByVal lpApplicationName As String, _
      ByVal lpKeyName As String, ByVal lpString As String, _
      ByVal lpFileName As String) As Integer

    Private Declare Ansi Function GetPrivateProfileInt _
      Lib "kernel32.dll" Alias "GetPrivateProfileIntA" _
      (ByVal lpApplicationName As String, _
      ByVal lpKeyName As String, ByVal nDefault As Integer, _
      ByVal lpFileName As String) As Integer

    Private Declare Ansi Function FlushPrivateProfileString _
      Lib "kernel32.dll" Alias "WritePrivateProfileStringA" _
      (ByVal lpApplicationName As Integer, _
      ByVal lpKeyName As Integer, ByVal lpString As Integer, _
      ByVal lpFileName As String) As Integer

    Dim strFilename As String

    ' Constructor, para aceptar el fichero INI
    Public Sub New(ByVal Filename As String)
        strFilename = Filename
    End Sub

    'Propiedad sólo lectura con nombre de fichero
    ReadOnly Property FileName() As String
        Get
            Return strFilename
        End Get
    End Property

    'Función para leer cadena de texto (string) de fichero INI
    Public Function GetString(ByVal Section As String, _
      ByVal Key As String, ByVal [Default] As String) As String
        Dim intCharCount As Integer
        Dim objResult As New System.Text.StringBuilder(256)

        intCharCount = GetPrivateProfileString(Section, Key, _
           [Default], objResult, objResult.Capacity, strFilename)
        If intCharCount > 0 Then
            GetString = Left(objResult.ToString, intCharCount)
        Else
            GetString = ""
        End If
    End Function

    'Función para leer un valor numérico del fichero INI
    Public Function GetInteger(ByVal Section As String, _
      ByVal Key As String, ByVal [Default] As Integer) As Integer
        Return GetPrivateProfileInt(Section, Key, _
           [Default], strFilename)
    End Function

    'Función para leer un valor booleano de fichero INI
    Public Function GetBoolean(ByVal Section As String, _
      ByVal Key As String, ByVal [Default] As Boolean) As Boolean
        Return (GetPrivateProfileInt(Section, Key, _
           CInt([Default]), strFilename) = 1)
    End Function

    'Función para escribir valor de cadena (string) en fichero INI
    Public Sub WriteString(ByVal Section As String, _
      ByVal Key As String, ByVal Value As String)
        WritePrivateProfileString(Section, Key, Value, strFilename)
        Flush()
    End Sub

    'Función para escribir valor numérico en fichero INI
    Public Sub WriteInteger(ByVal Section As String, _
      ByVal Key As String, ByVal Value As Integer)
        ' Writes an integer to your INI file
        WriteString(Section, Key, CStr(Value))
        Flush()
    End Sub

    'Función para escribir valor booleano en fichero INI
    Public Sub WriteBoolean(ByVal Section As String, _
    ByVal Key As String, ByVal Value As Boolean)
        ' Writes a boolean to your INI file
        WriteString(Section, Key, CStr(Math.Abs(CInt(Value))))
        Flush()
    End Sub

    'Guarda los cambios de la caché en fichero INI
    Private Sub Flush()
        FlushPrivateProfileString(0, 0, 0, strFilename)
    End Sub
End Class









Publicado el: 2011-04-23

Este sitio web NO CONTIENE malware, todos los programas con código fuente aquí. Autor: Alonso Javier Pérez Díaz