본문 바로가기
내꺼

hosts

by umaking 2009. 5. 22.

#include <vcl.h>

#include <stdio.h>

#pragma hdrstop


#include "Unit1.h"


//---------------------------------------------------------------------------

#pragma package(smart_init)

#pragma resource "*.dfm"

TForm1 *Form1;


//---------------------------------------------------------------------------

__fastcall TForm1::TForm1(TComponent* Owner)

    : TForm(Owner)

{

    char info[MAX_PATH+1];

    AnsiString str = "";

    FILE *f = NULL;


    GetEnvironmentVariable("SystemRoot", info, MAX_PATH);

    str.sprintf("%s\\system32\\drivers\\etc\\hosts", info);

    OutputDebugString(str.c_str());


    ZeroMemory(info, MAX_PATH);

    f = fopen(str.c_str(), "rt");

    if(f != NULL)

    {        

        while(fgets(info, MAX_PATH, f))

        {

            Memo1->Lines->Add(info);

//            OutputDebugString(info);

        }

        fclose(f);

    }


}

//---------------------------------------------------------------------------