unit disdos;

interface
uses dvCrt, dvWin, winProcs, strings, disvars;

function existeArq (nomearq: string): boolean;
function pegaParam (nome: string): string;
procedure trocaParam (nome: string; valorNovo: string);

implementation

{--------------------------------------------------------}
{                  ve se arquivo existe
{--------------------------------------------------------}

function existeArq (nomearq: string): boolean;
var existe: boolean;
    arq: file;
begin
    assign (arq, nomearq);
    {$I-}  reset (arq); {$i+}
    existe := ioresult = 0;
    if existe then close (arq);
    existeArq := existe;
end;

{--------------------------------------------------------}
{          pega um parametro de configuracao
{--------------------------------------------------------}

function pegaParam (nome: string): string;
var
    keyName, result, amb: array [0..144] of char;
begin
    strPCopy (keyName, nome);
    strPCopy (amb, ambDiscavox);
    GetPrivateProfileString('DISCAVOX', KeyName, '', result, 80, amb);
    pegaParam := strPas (result);
end;

{--------------------------------------------------------}
{          troca um parametro de configuracao
{--------------------------------------------------------}

procedure trocaParam (nome: string; valorNovo: string);
var
    keyName, newStr, amb: array [0..144] of char;
begin
    strPCopy (keyName, nome);
    strPCopy (newStr, valorNovo);
    strPCopy (amb, ambDiscavox);
    WritePrivateProfileString('DISCAVOX', KeyName, newStr, amb);
end;

end.