Clique abaixo para nos ajudar
Conectar-se

Esqueci minha senha

Estamos no Facebook
Buscar
 
 

Resultados por:
 


Rechercher Busca avançada

Quem está conectado
10 usuários online :: Nenhum usuário registrado, Nenhum Invisível e 10 Visitantes :: 2 Motores de busca

Nenhum

[ Ver toda a lista ]


O recorde de usuários online foi de 468 em 1/3/2012, 10:43
TRY BEGIN E FLOCK()

17/4/2017, 10:32 por AJC

Pessoal estou tendo alguns problemas de gravação em rede, estou usando
try begin, mas vi algo na …

Comentários: 0

Exportar Dados Campo Memo Tabela DBF

10/4/2017, 10:28 por fcampos

Olá bom dia.

Estou tentando exportar os dados de algumas tabelas em formato dbf pelo foxpro.
O …

Comentários: 2

Função EVL()

8/4/2017, 12:18 por Clebervfp

Bom dia a todos.
Vim compartilhar de uma Função do próprio VFP que me benefício muito.
Função …

Comentários: 0

COMO BLOQUEAR REGISTRO OU TABELA NO VISUAL FOXPRO PARA GRAVAÇÃO EM REDE

3/4/2017, 10:29 por AJC

Pessoal estou tendo um problema que acontece sempre busco na minha tabela de clientes o ultimo …

Comentários: 2

Controlar Scanner Twain

31/3/2017, 17:31 por Kleber R Bento

Estou usando o EZTW32.DLL para criar uma ferramenta que escaneia e gera PDF. Porém com esses …

Comentários: 0

Estatísticas
Temos 7079 usuários registrados
O último usuário registrado atende pelo nome de albsilva

Os nossos membros postaram um total de 48 mensagens em 25 assuntos

Arquivo INI

Ver o tópico anterior Ver o tópico seguinte Ir em baixo

Anexo Arquivo INI

Mensagem por Marcos Guedes em 28/8/2009, 14:05

Encontrei uma ótima rotina para leitura de arquivo .ini no seguinte link:
[Você precisa estar registrado e conectado para ver este link.]

Espero que seja útil aos colegas:
Código:
Imports System
Imports System.Text
Imports System.Collections
Imports System.Runtime.InteropServices
Imports Microsoft.VisualBasic

' The Org.Mentalis.Files contains a number of classes that read from or write to special files.
Namespace Org.Mentalis.Files

    Public Class IniReader
        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 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 GetPrivateProfileString Lib "kernel32.dll" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As StringBuilder, ByVal nSize As Integer, ByVal lpFileName As String) As Integer
        Private Declare Ansi Function GetPrivateProfileSectionNames Lib "kernel32" Alias "GetPrivateProfileSectionNamesA" (ByVal lpszReturnBuffer() As Byte, ByVal nSize As Integer, ByVal lpFileName As String) As Integer
        Private Declare Ansi Function WritePrivateProfileSection Lib "kernel32.dll" Alias "WritePrivateProfileSectionA" (ByVal lpAppName As String, ByVal lpString As String, ByVal lpFileName As String) As Integer
        Public Sub New(ByVal file As String)
            Filename = file
        End Sub
        Public Property Filename() As String
            Get
                Return m_Filename
            End Get
            Set(ByVal Value As String)
                m_Filename = Value
            End Set
        End Property
        Public Property Section() As String
            Get
                Return m_Section
            End Get
            Set(ByVal Value As String)
                m_Section = Value
            End Set
        End Property
        Public Function ReadInteger(ByVal section As String, ByVal key As String, ByVal defVal As Integer) As Integer
            Return GetPrivateProfileInt(section, key, defVal, Filename)
        End Function
        Public Function ReadInteger(ByVal section As String, ByVal key As String) As Integer
            Return ReadInteger(section, key, 0)
        End Function
        Public Function ReadInteger(ByVal key As String, ByVal defVal As Integer) As Integer
            Return ReadInteger(Section, key, defVal)
        End Function
        Public Function ReadInteger(ByVal key As String) As Integer
            Return ReadInteger(key, 0)
        End Function
        Public Function ReadString(ByVal section As String, ByVal key As String, ByVal defVal As String) As String
            Dim sb As New StringBuilder(MAX_ENTRY)
            Dim Ret As Integer = GetPrivateProfileString(section, key, defVal, sb, MAX_ENTRY, Filename)
            Return sb.ToString()
        End Function
        Public Function ReadString(ByVal section As String, ByVal key As String) As String
            Return ReadString(section, key, "")
        End Function
        Public Function ReadString(ByVal key As String) As String
            Return ReadString(Section, key)
        End Function
        Public Function ReadLong(ByVal section As String, ByVal key As String, ByVal defVal As Long) As Long
            Return Long.Parse(ReadString(section, key, defVal.ToString()))
        End Function
        Public Function ReadLong(ByVal section As String, ByVal key As String) As Long
            Return ReadLong(section, key, 0)
        End Function
        Public Function ReadLong(ByVal key As String, ByVal defVal As Long) As Long
            Return ReadLong(Section, key, defVal)
        End Function
        Public Function ReadLong(ByVal key As String) As Long
            Return ReadLong(key, 0)
        End Function
        Public Function ReadByteArray(ByVal section As String, ByVal key As String) As Byte()
            Try
                Return Convert.FromBase64String(ReadString(section, key))
            Catch
            End Try
            Return Nothing
        End Function
        Public Function ReadByteArray(ByVal key As String) As Byte()
            Return ReadByteArray(Section, key)
        End Function
        Public Function ReadBoolean(ByVal section As String, ByVal key As String, ByVal defVal As Boolean) As Boolean
            Return Boolean.Parse(ReadString(section, key, defVal.ToString()))
        End Function
        Public Function ReadBoolean(ByVal section As String, ByVal key As String) As Boolean
            Return ReadBoolean(section, key, False)
        End Function
        Public Function ReadBoolean(ByVal key As String, ByVal defVal As Boolean) As Boolean
            Return ReadBoolean(Section, key, defVal)
        End Function
        Public Function ReadBoolean(ByVal key As String) As Boolean
            Return ReadBoolean(Section, key)
        End Function
        Public Function Write(ByVal section As String, ByVal key As String, ByVal value As Integer) As Boolean
            Return Write(Section, key, value.ToString())
        End Function
        Public Function Write(ByVal key As String, ByVal value As Integer) As Boolean
            Return Write(Section, key, value)
        End Function
        Public Function Write(ByVal section As String, ByVal key As String, ByVal value As String) As Boolean
            Return (WritePrivateProfileString(section, key, value, Filename) <> 0)
        End Function
        Public Function Write(ByVal key As String, ByVal value As String) As Boolean
            Return Write(Section, key, value)
        End Function
        Public Function Write(ByVal section As String, ByVal key As String, ByVal value As Long) As Boolean
            Return Write(section, key, value.ToString())
        End Function
        Public Function Write(ByVal key As String, ByVal value As Long) As Boolean
            Return Write(Section, key, value)
        End Function
        Public Function Write(ByVal section As String, ByVal key As String, ByVal value() As Byte) As Boolean
            If value Is Nothing Then
                Return Write(section, key, CType(Nothing, String))
            Else
                Return Write(section, key, value, 0, value.Length)
            End If
        End Function
        Public Function Write(ByVal key As String, ByVal value() As Byte) As Boolean
            Return Write(Section, key, value)
        End Function
        Public Function Write(ByVal section As String, ByVal key As String, ByVal value() As Byte, ByVal offset As Integer, ByVal length As Integer) As Boolean
            If value Is Nothing Then
                Return Write(section, key, CType(Nothing, String))
            Else
                Return Write(section, key, Convert.ToBase64String(value, offset, length))
            End If
        End Function
        Public Function Write(ByVal section As String, ByVal key As String, ByVal value As Boolean) As Boolean
            Return Write(section, key, value.ToString())
        End Function
        Public Function Write(ByVal key As String, ByVal value As Boolean) As Boolean
            Return Write(Section, key, value)
        End Function
        Public Function DeleteKey(ByVal section As String, ByVal key As String) As Boolean
            Return (WritePrivateProfileString(Section, key, Nothing, Filename) <> 0)
        End Function
        Public Function DeleteKey(ByVal key As String) As Boolean
            Return (WritePrivateProfileString(Section, key, Nothing, Filename) <> 0)
        End Function
        Public Function DeleteSection(ByVal section As String) As Boolean
            Return WritePrivateProfileSection(section, Nothing, Filename) <> 0
        End Function
        Public Function GetSectionNames() As ArrayList
            Try
                Dim buffer(MAX_ENTRY) As Byte
                GetPrivateProfileSectionNames(buffer, MAX_ENTRY, Filename)
                Dim parts() As String = Encoding.ASCII.GetString(buffer).Trim(ControlChars.NullChar).Split(ControlChars.NullChar)
                Return New ArrayList(parts)
            Catch
            End Try
            Return Nothing
        End Function
        Private m_Filename As String
        Private m_Section As String
        Private Const MAX_ENTRY As Integer = 32768
    End Class
End Namespace

Obs: Precisei retirar a documentação pois o conteúdo estava grande para postar.
Não deixe de baixar o arquivo original:
[Você precisa estar registrado e conectado para ver este link.]

_________________
Marcos Guedes - Programador e desenvolvedor Web.


Visite o nosso portal:
[Você precisa estar registrado e conectado para ver este link.]

Marcos Guedes
Webmaster
Webmaster


Voltar ao Topo Ir em baixo

Anexo Re: Arquivo INI

Mensagem por Marcos Guedes em 28/8/2009, 14:05

Segue um exemplo de como utilizar a rotina:
Código:
Imports System
Imports System.Collections
Imports Org.Mentalis.Files

Public Class TestApp
    Public Shared Sub Main()
        Dim ini As New IniReader("c:\test.ini")
        ini.Write("Section1", "KeyString", "MyString")
        ini.Write("Section1", "KeyInt", 5)
        ini.Write("Section2", "KeyBool", True)
        ini.Write("Section2", "KeyBytes", New Byte() {0, 123, 255})
        ini.Write("Section3", "KeyLong", CType(123456789101112, Long))
        ini.Section = "Section1"
        Console.WriteLine("String: " + ini.ReadString("KeyString"))
        Console.WriteLine("Int: " + ini.ReadInteger("KeyInt", 0).ToString())
        Console.WriteLine("Bool: " + ini.ReadBoolean("Section2", "KeyBool", False).ToString())
        Console.WriteLine("Long: " + ini.ReadLong("Section3", "KeyLong", 0).ToString())
        Console.WriteLine("Byte 1 in byte array: " + (ini.ReadByteArray("Section2", "KeyBytes")(1)).ToString())
        ini.DeleteKey("Section2", "KeyBytes")
        ini.DeleteSection("Section3")
        Dim e As IEnumerator = ini.GetSectionNames().GetEnumerator()
        While e.MoveNext()
            Console.WriteLine(e.Current)
        End While
        Console.WriteLine("Press enter to continue...")
        Console.ReadLine()
    End Sub
End Class
Obs: Este exemplo foi retirado do próprio arquivo contido no seguinte link:
[Você precisa estar registrado e conectado para ver este link.]

_________________
Marcos Guedes - Programador e desenvolvedor Web.


Visite o nosso portal:
[Você precisa estar registrado e conectado para ver este link.]

Marcos Guedes
Webmaster
Webmaster


Voltar ao Topo Ir em baixo

Ver o tópico anterior Ver o tópico seguinte Voltar ao Topo


 
Permissão deste fórum:
Você não pode responder aos tópicos neste fórum