I used following line of code to change my computer name:
std::string mystr="MY-PC"
bSuccess = SetComputerNameA(mystr.c_str());
if( bSuccess == 0 )
printf("Unable to change computer name | ERROR %d |", GetLastError());
else
printf("Name changed successfully");
Upon executing the program, 'Name changed successfully' message appeared. Following registry items were found to have the update computer name
HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName
HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName
After restarting my computer, I checked the computer name from Control Panel\System and Security\System. To my surprise it still have the old name.
Checked the registry again which contain the new name i.e MY-PC
Any idea why the computer name at Control Panel\System and Security\System has not been updated?