Copy Registry and Calling an external apps!

This is a discussion on Copy Registry and Calling an external apps! within the C Programming forums, part of the General Programming Boards category; Does anybody know how can I copy something from registry then I write it to file. Also write something to ...

  1. #1
    Registered User xxxrugby's Avatar
    Join Date
    Jan 2005
    Posts
    178

    Copy Registry and Calling an external apps!

    Does anybody know how can I copy something from registry then I write it to file.
    Also write something to registry in C.

    Something like:
    HKEY_LOCAL_MACHINE\SOFTWARE\AFPL Ghostscript\8.11
    then i write it to filel like "fileold"
    and write a new name like
    HKEY_LOCAL_MACHINE\SOFTWARE\AFPL Ghostscript\10
    ________________________________________________

    Second how can I then lets say open "fileold" in notepad from
    C.
    That will be something like -> I ask do you wanna see your old registy?
    if yes -> notepad will open and in notepad will be text from "fileold".
    Sorry for spelling errors, not English!
    xxxrugby: "All Human Race Will Die From My Hand!"
    xxxrugby: "We are all philosophers, when question is about politics!"

  2. #2
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    I've never dealt much with the registry, but I imagine the ideal functions would be found in the Win32 API. In other words, MSDN can answer your question. You should be able to get some example source code there too.

    The simple solution to your second question is
    #include <stdlib.h>
    ...
    system("notepad fileold");
    Just be aware of the problems that system() causes. If notepad.exe no longer exists or something about the default directories has been tampered with, this won't work. Of course, since you're working with the registry, it's safe to assume that you're on a system which will have notepad, so it's not as big a concern as it normally would be.

    system() takes a char * as a pointer, but of course you can just put a string literal in there too (like I did). It executes said string as though it were entered in at the command prompt.

  3. #3
    Registered User xxxrugby's Avatar
    Join Date
    Jan 2005
    Posts
    178
    Than you on answering my second question. I will sure take a look on MSDN

    I try what you wrote to me and it working perfectly. Much thanks!
    Sorry for spelling errors, not English!
    xxxrugby: "All Human Race Will Die From My Hand!"
    xxxrugby: "We are all philosophers, when question is about politics!"

  4. #4
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,254
    Use RegOpenKeyEx() to open a registry key. Then use RegGetValue() to get the registry value. To write a new value, use RegSetValueEx(), and finally to close a key use RegCloseKey().

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21