Bom dia, estou desenvolvendo uma aplicação em pascal que bloqueia sites, trabalhando em cima do arquivo de texto hosts do windows, " C:\WINDOWS\system32\drivers\etc\Hosts ". os bloqueio está funcionando perfeitamente onde utilizo append que adiciona o site na ultima linha do arquivo , mas agora estou com problema para apagar o site que eu quero ex: no programa quero digitar o site dar ENTER e ele bloquear.
Por enquanto estou conseguindo bloquear só sobrescrevendo todo arquivo desta forma:
const caminhoarRostes = 'C:\WINDOWS\system32\drivers\etc\Hosts'; var arRostes :text; arqedicao: String;beginassign(arRostes,caminhoarRostes);rewrite(arRostes);writeln(arRostes, '# Copyright (c) 1993-2009 Microsoft Corp.');writeln(arRostes, '#');writeln(arRostes, '# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.');writeln(arRostes, '#');writeln(arRostes, '# This file contains the mappings of IP addresses to host names. Each');writeln(arRostes, '# entry should be kept on an individual line. The IP address should');writeln(arRostes, '# be placed in the first column followed by the corresponding host name.');writeln(arRostes, '# The IP address and the host name should be separated by at least one');writeln(arRostes, '# space.');writeln(arRostes, '#');writeln(arRostes, '# Additionally, comments (such as these) may be inserted on individual');writeln(arRostes, '# lines or following the machine name denoted by a # symbol.');writeln(arRostes, '#');writeln(arRostes, '# For example:');writeln(arRostes, '#');writeln(arRostes, '# 102.54.94.97 rhino.acme.com # source server');writeln(arRostes, '# 38.25.63.10 x.acme.com # x client host');writeln(arRostes, '');writeln(arRostes, '# localhost name resolution is handled within DNS itself.');writeln(arRostes, '# 127.0.0.1 localhost');writeln(arRostes, '# ::1 localhost');writeln(arRostes, '');writeln(arRostes, '127.0.0.1 localhost');close(arRostes);readkey;end.
Pesquisei um pouco mas não entendi como eu posso fazer criando um arquivo temporario e depois voltando arquivo só com os dados que quero.
Obrigado Galera.