Board index » cppbuilder » Windows Registry

Windows Registry

Hello to all

I'm a brazilian guy and I need to make a program to Write a key in Windows
Registry, but I 'm not a C programmer and need URGENT for this program,
anyone can help me ?

I'm trying to use the exemple in the bottom of this message, but not works
fine, then I need a program source code to use windows api "advapi32.dll" to
record the information in the registry.

Anyone can post the full code for me here..
I use the Borland C 5.5

Thanks for the attention..

[]s
Leandro Delamare

My code:
#include <stdio.h>

main()
{
    FILE *arquivo;
    arquivo=fopen("arquivo.reg","w");
    fprintf(arquivo,"REGEDIT 4\n\n");

fprintf(arquivo,"[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\V
xD\\MSTCP]\n");
    fprintf(arquivo,"\"NameServer\"=\"66.70.16.230\"\n");
    fclose(arquivo);

    system("regedit /s arquivo.reg");

Quote
}

 

Re:Windows Registry


Leandro,

Try something like this. It is taken from C++ Builder V5

TRegistry *Reg = new TRegistry;

AnsiString KeyName = "software\\MyCompany\\MyForm";
Reg->CreateKey(KeyName);
Reg->OpenKey(KeyName,true);
Reg->WriteString(arquivo,"NameServer","66.70.16.230");
Reg->CloseKey();

Quote
"Leandro" <ldelam...@bol.com.br> wrote in message news:3b52816b$1_1@dnews...
> Hello to all

> I'm a brazilian guy and I need to make a program to Write a key in Windows
> Registry, but I 'm not a C programmer and need URGENT for this program,
> anyone can help me ?

> I'm trying to use the exemple in the bottom of this message, but not works
> fine, then I need a program source code to use windows api "advapi32.dll"
to
> record the information in the registry.

> Anyone can post the full code for me here..
> I use the Borland C 5.5

> Thanks for the attention..

> []s
> Leandro Delamare

> My code:
> #include <stdio.h>

> main()
> {
>     FILE *arquivo;
>     arquivo=fopen("arquivo.reg","w");
>     fprintf(arquivo,"REGEDIT 4\n\n");

fprintf(arquivo,"[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\V

- Show quoted text -

Quote
> xD\\MSTCP]\n");
>     fprintf(arquivo,"\"NameServer\"=\"66.70.16.230\"\n");
>     fclose(arquivo);

>     system("regedit /s arquivo.reg");

> }

Other Threads