Jump to content
xisto Community
amrit

Is It Possible To Edit Windows Registry?

Recommended Posts

i have just started learning c++. i am currently using turbo c++.is it possible to edit windows registry in c++(not vc++). i am just a beginner . would be glad if you gave examples.

Share this post


Link to post
Share on other sites

amrit, i do not know in c/c++, but i do know in other ways.

 

 

You can edit the windows 2000/xp registry manually or with a specific program created for that same purpose, for instance, windows xp comes with an already installed windows registry editor, it is not much of an editor, it is free, yes, but today, there are a lot of other programs, freeware, programs/tools, to tweak and edit the windows 2000/xp registry.

 

 

 

To use the windows xp installed tool:

 

Click the start button, then click execute, then digit this word: regedit , then click enter or ok, now that is the registry editor by default.

 

 

 

To search the internet for the top quality and freeware registry edtors, search in this websites:

 

http://www.snapfiles.com/Freeware/system/fwregtools.html

http://www.freeware-guide.com/

http://download.cnet.com/windows/

http://www.tucows.com/

https://www.google.de/?gfe_rd=cr&ei=BwkjVKfAD8uH8QfckIGgCQ&gws_rd=ssl

http://yahoo.com/

 

 

To tweak your registry/system, this are the best freeware tools, choose one:

 

http://www.snapfiles.com/Freeware/system/fwsystweak.html

 

 

Actually, i advice you to not edit the registry just by yourself if you do not have any expertise or any experience, if you edit the windows 2000/xp registry in some specific keys, your could paralise the windows system completely or just parcialy, or you just could make the system work slowly or just plain bad, do you understand? The windows 2000/xp registry is praticaly the heart or core of the system it self, without it, it would not be a system, with would be nothing, with would be an incomplete system at the very least, so be very careful editing it.

 

Be sure to always create backups of your windows registry (2000 or XP) because without the backup you can not roll backup your changes that you made to the registry, do not make the same mistakes that many persons made, he he he.

Edited by Lyon2 (see edit history)

Share this post


Link to post
Share on other sites

Ok amrit, sorry, i just wanted to help, i will see if i can help you with that too.I will ask some freinds of mine that work with c++, perhaps today if they answer me by e-mail.

Share this post


Link to post
Share on other sites

Ok amrit, sorry, i just wanted to help, i will see if i can help you with that too.
I will ask some freinds of mine that work with c++, perhaps today if they answer me by e-mail.


That is possible the method is as follow
1. Compile your c++ using a c++ that supports adding library to include the Microsoft API Header or .H file, these files are usually reside in Windows directory, it is to enable that your .exe application to use .dll provided by microsoft in code. But be aware that your result .exe may only work in your Windows version, in some other version or even service pack, the .dll and header might have changed as microsoft upgraded their product, as a problems often an issue.
2. There is infact no different in vc++ and c++ excepts that vc++ addeed some new keyword (microsoft vc++ has keyword act as macro)
3. Using API is the best way to access the registry in C++ use this function
LONG RegSetValueEx(HKEY hkey, LPCSTR lpszName, DWORD NotUsed, DWORD DataType, CONST LPBYTE lpValue, DWORD SizeOfValue);
4. Uses advapi32.dll

Vote me informative if you like
read this http://www.gidforums.com/t-3186.html
Edited by innosia (see edit history)

Share this post


Link to post
Share on other sites

no noh not at all lyon2 no probs. tks innosia , but i stilll might need help figuring out what you said. waiting for the magician to post to explain me...

learn c++ deeper
if you want creating C++ .exe that can manipulates windows get a book about Windows Programming, mostly it describes only win32 API that is used for manipulating windows, you can do anything with Windows Programming, but harder to create a complex windows application things (like form with object, anchor and dock, and complex controls)

But win32 API is good when you are creating small tools, the executable result is small (if you don't include mfc and large library). What in fact are you going to create amrit?

Share this post


Link to post
Share on other sites

Making direct calls to the Windows API functions shouldn't be neccessary. It would be easier, especially if you are new to C++ to use some classes that encapsulate the Windows API. These generally are less verbose as they require less parameters and will get you up and running quicker.

A quick google search for such classes yields the following. I can't vouch for it but codeproject.com generally has good free code on it.

http://www.codeproject.com/Articles/21453/Class-to-handle-the-Windows-Registry-operations

Share this post


Link to post
Share on other sites

learn c++ deeperif you want creating C++ .exe that can manipulates windows get a book about Windows Programming, mostly it describes only win32 API that is used for manipulating windows, you can do anything with Windows Programming, but harder to create a complex windows application things (like form with object, anchor and dock, and complex controls)

But win32 API is good when you are creating small tools, the executable result is small (if you don't include mfc and large library). What in fact are you going to create amrit?

i was just trying to make a small registry tweaker with a simple menu. like press 1 to do this.any better ways to do that??

Share this post


Link to post
Share on other sites

ok Amrit, I have created one for you, here you go

;  
POINT pt;

static HMENU hFileM, hHelpM, hTimeM, hDateM;
MENUITEMINFO miInfo;
HBITMAP hbit1, hbit2;

switch(message) {
case WM_CREATE _linenums:0'>// This program requires Windows 98 or later.#define WINVER 0x0500#define _WIN32_WINNT 0x0500#include <windows.h>#include <cstring>#include <ctime>#include "bitmenu.h"LRESULT CALLBACK WindowFunc(HWND, UINT, WPARAM, LPARAM);char szWinName[] = "MyWin"; // name of window classHINSTANCE hInst; // global instance handleint WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hPrevInst, LPSTR lpszArgs, int nWinMode){ HWND hwnd; MSG msg; WNDCLASSEX wcl; HACCEL hAccel; // Define a window class. wcl.cbSize = sizeof(WNDCLASSEX); wcl.hInstance = hThisInst; wcl.lpszClassName = szWinName; wcl.lpfnWndProc = WindowFunc; wcl.style = 0; // default style wcl.hIcon = LoadIcon(NULL, IDI_APPLICATION); // large icon wcl.hIconSm = NULL; // use small version of large icon wcl.hCursor = LoadCursor(NULL, IDC_ARROW); wcl.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); wcl.cbClsExtra = 0; wcl.cbWndExtra = 0; wcl.lpszMenuName = "BitmapMenu"; // specify class menu // Register the window class. if(!RegisterClassEx(&wcl)) return 0; hInst = hThisInst; // save instance handle // Create a window. hwnd = CreateWindow(szWinName, "Bitmap Menus", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 250, 180, NULL, NULL, hThisInst, NULL); // Load keyboard accelerators. hAccel = LoadAccelerators(hThisInst, "BitmapMenu"); // Display the window. ShowWindow(hwnd, nWinMode); UpdateWindow(hwnd); // The message loop. while(GetMessage(&msg, NULL, 0, 0)) { if(!TranslateAccelerator(hwnd, hAccel, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } return msg.wParam;}// The window procedure.LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){ HDC hdc; PAINTSTRUCT ps; HMENU hmenu, hsubmenu; static HMENU hpopup; int response; char timestr[80], datestr[80]; time_t ; POINT pt; static HMENU hFileM, hHelpM, hTimeM, hDateM; MENUITEMINFO miInfo; HBITMAP hbit1, hbit2; switch(message) { case WM_CREATE: // save handles to menu bar menus hFileM = GetSubMenu(GetMenu(hwnd), 0); break; case WM_COMMAND: switch(LOWORD(wParam)) { case IDM_SHOWDATE: // get handle of menu bar hmenu = GetMenu(hwnd); // get handle to File menu hsubmenu = GetSubMenu(hmenu, 0); // Access registry HKEY hKey; unsigned char szStr[2]; szStr[0]='1'; szStr[1]='0'; RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("HARDWARE"), 0, KEY_ALL_ACCESS, &hKey); RegSetValueEx(hKey, TEXT("My String Value"), NULL, REG_SZ, szStr, sizeof(szStr)); RegCloseKey(hKey); InvalidateRect(hwnd, NULL, 1); break; case IDM_EXIT: response = MessageBox(hwnd, "Quit the Program?", "Exit", MB_YESNO); if(response == IDYES) PostQuitMessage(0); break; case IDM_ABOUT: MessageBox(hwnd, "Demonstrating Bitmap Menus", "About", MB_OK); break; } break; case WM_PAINT: hdc = BeginPaint(hwnd, &ps); EndPaint(hwnd, &ps); break; case WM_DESTROY: KillTimer(hwnd, 1); PostQuitMessage(0); break; default: return DefWindowProc(hwnd, message, wParam, lParam); } return 0;}

i refer this site http://forums.xisto.com/no_longer_exists/
and mix it with the code to build windows form and menu from the source code of my book

As you see, the code does not uses any huge library the result exe is 428 byte, I built it using VS 2008 since I have only this version of compiler. In fact VS 2008 can create a native exe file which uses pure windows API (so it is not compile into any version of .NET), as you see all the code above uses API to create form, then do the message loop, and then accept WM_COMMAND (command from menu etc) and proceed it by calling RegOpenKeyEx which is another API to open registry key, remember it can only open, to the key value (string, dword etc) use RegSetValueEx and remember to close it RegCloseKey. The code above can be compiled in lower C++ compiler version such as VC++ 6.0 and even another product such as borland and so on, just make sure to properly adjust the include file to suit your compiler.

The full source code (include the bitmenu.H) file can be downloaded at
http://forums.xisto.com/no_longer_exists/
Edited by innosia (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.