Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #12  
Antiguo 06-05-2012
Fakedo0r Fakedo0r is offline
Registrado
NULL
 
Registrado: may 2012
Posts: 1
Poder: 0
Fakedo0r Va por buen camino
Hola, gracias por tu codigo. Por cierto, desconocia ese error que con cuentas limitadas se producen errores. En todo caso, aqui te dejo una alternativa mia que no me ha dado ningun error hasta hora.

Código Delphi [-]
//******************************************************************************
//* UNIT:         UNT_GetWriteINI
//* AUTOR:        Fakedo0r
//* FECHA:        14.04.2012
//* CORREO:       Luvel88@gmail.com
//* BLOG:         Sub-Soul.blogspot.com
//* DESCRIPCION:  Permite Leer / Escribir ficheros tipo *.INI
//* USO:          GetINI('C:\Config.ini', 'Opciones', 'Puerto', '');
//*               WriteINI('C:\Config.ini', 'Opciones', 'Puerto', '5005');
//******************************************************************************
unit UNT_GetWriteINI;
//******************************************************************************
//DECLARACION DE LIBRERIAS / CLASES
//******************************************************************************
interface

uses
  Winapi.Windows, System.SysUtils;
//******************************************************************************
//DECLARACION DE FUNCIONES / PROCEDIMIENTOS
//******************************************************************************
function GetINI(sPath: String; sName: String; sKeyName: String; sDefault: String): String;
function WriteINI(sPath: String; sName: String; sKeyName: String; sValor: String): Bool;
//******************************************************************************
implementation
//******************************************************************************
//<--- LEE FICHEROS *.INI --->
//******************************************************************************
function GetINI(sPath: String; sName: String; sKeyName: String; sDefault: String): String;
var
  dwFile:   DWORD;
  sBuffer:  String;
  iSize:    Integer;
begin
  iSize := 0;
  dwFile := CreateFile(PChar(sPath), GENERIC_READ, FILE_SHARE_READ, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
  iSize := GetFileSize(dwFile, 0);

  if iSize = - 1 then exit;

  SetLength(sBuffer, iSize);
  iSize := GetPrivateProfileString(PChar(sName), PChar(sKeyName), PChar(sDefault), PChar(sBuffer), iSize, PChar(sPath));

  Result := Copy(sBuffer, 1, iSize);
end;
//******************************************************************************
//<--- ESCRIBE FICHEROS *.INI --->
//******************************************************************************
function WriteINI(sPath: String; sName: String; sKeyName: String; sValor: String): Bool;
begin
  if WritePrivateProfileString(PChar(sName), PChar(sKeyName), PChar(sValor), PChar(sPath)) = True then
    Result := True
  Else
    Result := False;
end;

end.

Saludo.
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Proyecto en partes jevo19100 OOP 17 24-05-2007 18:44:48
Archivos de un proyecto elcigarra Varios 3 23-11-2005 15:30:43
Incluir una dll en un proyecto LoBo2024 Varios 5 26-08-2004 10:58:30
Proyecto MDI? danytorres Varios 2 29-10-2003 15:52:25


La franja horaria es GMT +2. Ahora son las 10:30:00.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi