Hey guys, sorry I am still working on c++ and trying to experiement a few things. I worked with MSDN and did alot of research, but I came across a few problems hopefully you could help me out.
I am basically trying to change the hostname and domain and hopefully anything else I come across by modifying the registry using C++.
Full Source:
Code:
#include <iostream>
#include <windows.h>
using namespace std; // Eliminating scope resolution operator
char const* text; // set variable text char type as const
HKEY hKey;
int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil)
{
cout << "Hostname Value";
cin >> text; //Input Text into variable "text"
RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\ComputerName\\ActiveComputerName", 0, KEY_SET_VALUE, &hKey);
RegSetValueEx(hKey, "ComputerName", 0, REG_SZ, (LPBYTE)(LPTSTR)text, MAX_PATH);
RegCloseKey(hKey);
return 0;
}
[Application]
Using Bloodshed devc++ -> Console Application
[Error]
The only error it seems to be pointing to is text is not a valid type of input. Like I tried to set it as a string to see if it accepts my input, tried char alone to see if it accepts my input, but it's pretty much the same outcome. It fails to compile.