Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //******************************************************************************
- //* 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.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement