Login

Esqueci minha senha

Estamos no Facebook
Buscar
 
 

Resultados por:
 


Rechercher Busca avançada

Quem está conectado
26 usuários online :: 1 usuário cadastrado, Nenhum Invisível e 25 Visitantes :: 2 Motores de busca

thiag0ms

[ Ver toda a lista ]


O recorde de usuários online foi de 468 em 1/3/2012, 10:43
Brasília
Estamos no Twitter
Nossa Comunidade
Nosso Grupo
Últimos assuntos
» Erro no Projeto Chat
Hoje à(s) 11:38 por Sub-Zero

» Modificar TitleBar e Icone do Executavel.
Hoje à(s) 11:24 por Sub-Zero

» Criar atalho, SYS(2020) e Desktop
Ontem à(s) 23:07 por Sub-Zero

» Karaoke feito em FoxPro 2.6
Ontem à(s) 18:51 por Sub-Zero

» Como separar caminho do diretório?
Ontem à(s) 18:49 por Sub-Zero

» Utilizando PHPMailer
Ontem à(s) 09:45 por paulomelo

» Programador em Visual Foxpro
Ontem à(s) 09:03 por mauro victoria

» Link PHP (Dúvida)
21/5/2012, 08:25 por BrunoMesquita

» Fundo do PROJETO Transparente??
20/5/2012, 19:48 por thiag0ms

» Minimizar , Maximizar e Restaurar
18/5/2012, 16:28 por FERNANDOMATRELLA

» Pivot Table no sql server
15/5/2012, 12:35 por edspicer

» Scroll EditBox Automatico
14/5/2012, 10:31 por Julio

» Select Nexval do FoxPro no OracleXE
10/5/2012, 00:16 por Sub-Zero

» Colocar gif na caixa do MESSAGEBOX ()
9/5/2012, 14:39 por Linghston

» Comparar Versões do programa.exe
8/5/2012, 16:10 por Linghston

» Menu lateral
7/5/2012, 02:36 por lardecristo

» Fazer com que a tela do sistema assume a janela principal
7/5/2012, 02:20 por lardecristo

» Trocar Palavra no Sistema
7/5/2012, 01:55 por lardecristo

» invocar Dll em Xbase
7/5/2012, 01:18 por lardecristo

» Fechar Porta Aberta
7/5/2012, 01:00 por lardecristo

Erro no Projeto Chat

2/5/2012, 08:37 por renatojunior2009

Bom dia Pessoal,

Estou desenvolvendo um chat , só que estou com dois erros o qual eu não sei …

Comentários: 7

Modificar TitleBar e Icone do Executavel.

23/5/2012, 20:17 por thiag0ms

Oi, tem como desabilitar o botao de Maximizar do TitleBar...

Eu keria simular uma TitleBar...mais …

Comentários: 5

Criar atalho, SYS(2020) e Desktop

23/5/2012, 17:57 por thiag0ms

Ola denovo...3 dúvidas...

como diz o título do tópico eu queria como criar uma atalho no …

Comentários: 3

Karaoke feito em FoxPro 2.6

23/5/2012, 11:45 por fabiomacarrao

Bom dia a todos. Desenvolvi um programa em FoxPro for windows 2.6 para karaoke. tenho mais de 2700 …

Comentários: 3

Como separar caminho do diretório?

20/5/2012, 21:30 por thiag0ms

tentei di muitas formas mais ainda não consegui...

bom, eu fis uma rotininha para que quando o …

Comentários: 10

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

Os nossos membros postaram um total de 14433 mensagens em 2047 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, 13:43

Encontrei uma ótima rotina para leitura de arquivo .ini no seguinte link:
mentalis.org/soft/class.qpx?id=6

Espero que seja útil aos colegas:
Código:
using System;
using System.Text;
using System.Collections;
using System.Runtime.InteropServices;

namespace Org.Mentalis.Files
{
    public class IniReader
    {
        // API declarations
        [DllImport("KERNEL32.DLL", EntryPoint = "GetPrivateProfileIntA", CharSet = CharSet.Ansi)]
        private static extern int GetPrivateProfileInt(string lpApplicationName, string lpKeyName, int nDefault, string lpFileName);
        [DllImport("KERNEL32.DLL", EntryPoint = "WritePrivateProfileStringA", CharSet = CharSet.Ansi)]
        private static extern int WritePrivateProfileString(string lpApplicationName, string lpKeyName, string lpString, string lpFileName);
        [DllImport("KERNEL32.DLL", EntryPoint = "GetPrivateProfileStringA", CharSet = CharSet.Ansi)]
        private static extern int GetPrivateProfileString(string lpApplicationName, string lpKeyName, string lpDefault, StringBuilder lpReturnedString, int nSize, string lpFileName);
        [DllImport("KERNEL32.DLL", EntryPoint = "GetPrivateProfileSectionNamesA", CharSet = CharSet.Ansi)]
        private static extern int GetPrivateProfileSectionNames(byte[] lpszReturnBuffer, int nSize, string lpFileName);
        [DllImport("KERNEL32.DLL", EntryPoint = "WritePrivateProfileSectionA", CharSet = CharSet.Ansi)]
        private static extern int WritePrivateProfileSection(string lpAppName, string lpString, string lpFileName);
        public IniReader(string file)
        {
            Filename = file;
        }       
        public string Filename
        {
            get
            {
                return m_Filename;
            }
            set
            {
                m_Filename = value;
            }
        }       
        public string Section
        {
            get
            {
                return m_Section;
            }
            set
            {
                m_Section = value;
            }
        }       
        public int ReadInteger(string section, string key, int defVal)
        {
            return GetPrivateProfileInt(section, key, defVal, Filename);
        }       
        public int ReadInteger(string section, string key)
        {
            return ReadInteger(section, key, 0);
        }       
        public int ReadInteger(string key, int defVal)
        {
            return ReadInteger(Section, key, defVal);
        }       
        public int ReadInteger(string key)
        {
            return ReadInteger(key, 0);
        }       
        public string ReadString(string section, string key, string defVal)
        {
            StringBuilder sb = new StringBuilder(MAX_ENTRY);
            int Ret = GetPrivateProfileString(section, key, defVal, sb, MAX_ENTRY, Filename);
            return sb.ToString();
        }       
        public string ReadString(string section, string key)
        {
            return ReadString(section, key, "");
        }       
        public string ReadString(string key)
        {
            return ReadString(Section, key);
        }       
        public long ReadLong(string section, string key, long defVal)
        {
            return long.Parse(ReadString(section, key, defVal.ToString()));
        }       
        public long ReadLong(string section, string key)
        {
            return ReadLong(section, key, 0);
        }       
        public long ReadLong(string key, long defVal)
        {
            return ReadLong(Section, key, defVal);
        }       
        public long ReadLong(string key)
        {
            return ReadLong(key, 0);
        }       
        public byte[] ReadByteArray(string section, string key)
        {
            try
            {
                return Convert.FromBase64String(ReadString(section, key));
            }
            catch { }
            return null;
        }       
        public byte[] ReadByteArray(string key)
        {
            return ReadByteArray(Section, key);
        }       
        public bool ReadBoolean(string section, string key, bool defVal)
        {
            return Boolean.Parse(ReadString(section, key, defVal.ToString()));
        }       
        public bool ReadBoolean(string section, string key)
        {
            return ReadBoolean(section, key, false);
        }       
        public bool ReadBoolean(string key, bool defVal)
        {
            return ReadBoolean(Section, key, defVal);
        }       
        public bool ReadBoolean(string key)
        {
            return ReadBoolean(Section, key);
        }       
        public bool Write(string section, string key, int value)
        {
            return Write(section, key, value.ToString());
        }       
        public bool Write(string key, int value)
        {
            return Write(Section, key, value);
        }       
        public bool Write(string section, string key, string value)
        {
            return (WritePrivateProfileString(section, key, value, Filename) != 0);
        }       
        public bool Write(string key, string value)
        {
            return Write(Section, key, value);
        }       
        public bool Write(string section, string key, long value)
        {
            return Write(section, key, value.ToString());
        }       
        public bool Write(string key, long value)
        {
            return Write(Section, key, value);
        }       
        public bool Write(string section, string key, byte[] value)
        {
            if (value == null)
                return Write(section, key, (string)null);
            else
                return Write(section, key, value, 0, value.Length);
        }       
        public bool Write(string key, byte[] value)
        {
            return Write(Section, key, value);
        }       
        public bool Write(string section, string key, byte[] value, int offset, int length)
        {
            if (value == null)
                return Write(section, key, (string)null);
            else
                return Write(section, key, Convert.ToBase64String(value, offset, length));
        }       
        public bool Write(string section, string key, bool value)
        {
            return Write(section, key, value.ToString());
        }       
        public bool Write(string key, bool value)
        {
            return Write(Section, key, value);
        }       
        public bool DeleteKey(string section, string key)
        {
            return (WritePrivateProfileString(section, key, null, Filename) != 0);
        }       
        public bool DeleteKey(string key)
        {
            return (WritePrivateProfileString(Section, key, null, Filename) != 0);
        }       
        public bool DeleteSection(string section)
        {
            return WritePrivateProfileSection(section, null, Filename) != 0;
        }       
        public ArrayList GetSectionNames()
        {
            try
            {
                byte[] buffer = new byte[MAX_ENTRY];
                GetPrivateProfileSectionNames(buffer, MAX_ENTRY, Filename);
                string[] parts = Encoding.ASCII.GetString(buffer).Trim('\0').Split('\0');
                return new ArrayList(parts);
            }
            catch { }
            return null;
        }

        private string m_Filename;       
        private string m_Section;       
        private const int MAX_ENTRY = 32768;
    }
}


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.]


Última edição por Marcos Guedes em 20/7/2010, 14:20, editado 1 vez(es)

_________________
Marcos Guedes - Programador e desenvolvedor Web.

Convidado, seja nosso seguidor no Twitter:
twitter.com/programacaobras

Marcos Guedes
Webmaster
Webmaster


Voltar ao Topo Ir em baixo

Anexo Re: Arquivo INI

Mensagem por Marcos Guedes em 28/8/2009, 13:45

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

public class TestApp {
   public static void Main() {
      IniReader ini = 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", (long)123456789101112);
      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");
      IEnumerator e = ini.GetSectionNames().GetEnumerator();
      while(e.MoveNext()) {
         Console.WriteLine(e.Current);
      }
      Console.WriteLine("Press enter to continue...");
      Console.ReadLine();
   }
}


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.

Convidado, seja nosso seguidor no Twitter:
twitter.com/programacaobras

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