|
|
|
|
|
Dicas
|
|
Visual Basic.Net (Arquivos/Diretórios)
|
|
|
Título da Dica: Leitura e Escrita em Arquivos INI
|
|
|
|
Postada em 14/7/2004 por ixeyc
'declare em um module BAS
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 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 Ret As String Public Sub WriteINI(filename As String, Section As String, Key As String, Text As String) WritePrivateProfileString Section, Key, Text, filename End Sub Public Function ReadINI(filename As String, Section As String, Key As String) Ret = Space$(255) RetLen = GetPrivateProfileString(Section, Key, "", Ret, Len(Ret), filename) Ret = Left$(Ret, RetLen) ReadINI = Ret End Function
A leitura e a escrita se torna do mesmo jeito do que uma estrutura de um banco de dados onde se tem: Banco, Tabela e Campo...
pra escrever: WriteINI "C:ARQ.INI", "Impressora", "Impressora", cmbImpressora
pra ler: ReadINI("C:ARQ.INI", "Impressora", "Impressora")
|
|
|
|
|