Ir para conteúdo
Fórum Script Brasil

Gamaliel

Membros
  • Total de itens

    4
  • Registro em

  • Última visita

Posts postados por Gamaliel

  1. Public Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
    Public Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
    
    
    Public Function pFncLeArquivoIni(cArquivo As String, cSessao As String, cParametro As String, Optional lVerificaArquivo As Boolean = True) As String
        
        Dim nTamanhoRetorno As Long
        Dim cRetorno        As String
    
        cRetorno = Space(255)
        cParametro = UCase(cParametro)
    
        If lVerificaArquivo Then
            If Dir(cArquivo) = "" Then
                pFncLeArquivoIni = ""
                Exit Function
            End If
        End If
    
        nTamanhoRetorno = GetPrivateProfileString(UCase(cSessao), cParametro, "", cRetorno, Len(cRetorno), cArquivo)
        If nTamanhoRetorno > 0 Then
            cRetorno = Left(cRetorno, nTamanhoRetorno)
            pFncLeArquivoIni = cRetorno
        Else
            pFncLeArquivoIni = ""
        End If
        
    End Function
    
    Public Function pFncEscArqIni(cSecao As String, cNomeChave As String, cValor As String, cArquivoINI As String) As Integer
    
        Dim nRetorno As Integer
    
        On Error GoTo TrataErro
    
        nRetorno = WritePrivateProfileString(cSecao, cNomeChave, cValor, cArquivoINI)
        If nRetorno = False Then
            pFncEscArqIni = 1
        End If
    
        pFncEscArqIni = 0
        Exit Function
    
    TrataErro:
        Err.Clear
        pFncEscArqIni = 2
    
    End Function

    Espero te-lo ajudado. :lol:

×
×
  • Criar Novo...