help me convert a batch file to C++...please

This is a discussion on help me convert a batch file to C++...please within the Windows Programming forums, part of the Platform Specific Boards category; I made a batch file to edit the registryo on my computer. How would this code look in C++? Code: ...

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    11

    help me convert a batch file to C++...please

    I made a batch file to edit the registryo on my computer.
    How would this code look in C++?

    Code:
    copy swap.bat "C:\windows\snaplecrackle.bat" /y
    reg add "HKCU\Control Panel\Mouse" /v SwapMouseButtons /t REG_SZ /d 1 /f
    reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run" /v snaplecrackle /t REG_SZ /d C:\windows\snaplecrackle.bat /y
    del swap.bat /y
    the spacing kind of got screwed up when i pasted it, I would really appreciate any help on this subject.

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    106
    I don't think you want to do this with C++. Some sort of visual basic or MSI derived installer would work better for this.

  3. #3
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398
    Consider re-posting your question on the Windows forum...

    Almost anything you can do from the command line or a batch file, you can do with the system() command. You would probably have to put the 'Y' confirmation into an if-statement.

    There are WinAPI functions to read / write the registry. I've never done it myself, but I found this on MSDN.

    ...Registry API Flavors and New Functions

    There are basically three ways to program the registry: the Win32 API functions (advapi32.dll), the more recent Shell Lightweight API (shlwapi.dll), and various object models accessible mostly from Visual Basic® and Windows Script Host....

    ...The original set of registry functions provides you with the greatest flexibility. It requires you to open a key, to read or write to it, and then close it; the three basic operations for reading or writing an individual entry.

    The Shell Lightweight library—also available with Windows 98, Windows 95, and Windows NT 4.0 plus Internet Explorer 5.0 or higher—comes with some new functions that internally open and close the specified key when asked to read or write values. You just call SHGetValue or SHSetValue and let the function deal with the registry. In addition, the new API provides a SHDeleteKey function that recursively deletes non-empty keys....

    ...The Windows 2000 SDK introduces three new functions that work with the registry: RegOpenUserClassesRoot, RegOpenCurrentUser, and RegDisablePredefinedCache. RegOpenUserClassesRoot returns a handle to HKCR for the specified user...

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,848
    moved

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. batch file introduction in multiprocesses program
    By c_geek in forum C Programming
    Replies: 0
    Last Post: 03-27-2008, 02:52 PM
  2. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  3. ? to convert a C file to a (*.scr) file
    By Dubi in forum Windows Programming
    Replies: 2
    Last Post: 03-02-2004, 07:35 AM
  4. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 05:10 PM
  5. File I/O convert
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 10-03-2001, 09:10 AM

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