Hello everyone, i have troubles in school project that need to add window 98's registry using Visual C++, do you have any ideas on how to do it thanks for helping.
// registry_write.cpp // compile with: /clr using namespace System; using namespace Microsoft::Win32;
int main() { // The second OpenSubKey argument indicates that // the subkey should be writable. RegistryKey^ rk; rk = Registry::CurrentUser->OpenSubKey("Software", true); if (!rk) { Console::WriteLine("Failed to open CurrentUser/Software key"); return -1; }
RegistryKey^ nk = rk->CreateSubKey("NewRegKey"); if (!nk) { Console::WriteLine("Failed to create 'NewRegKey'"); return -1; }
String^ newValue = "NewValue"; try { nk->SetValue("NewKey", newValue); nk->SetValue("NewKey2", 44); } catch (Exception^) { Console::WriteLine("Failed to set new values in 'NewRegKey'"); return -1; }
Thanks for reply my question. The project is about to add registry into window 98 so that when we insert portable device into computer, it won't appear "Add new hardware wizard" but it can detect it directly. How can i do that thank you.
Windows registry
Wisdomtool
Hi,
Here's a sample (from MSDN):
// registry_write.cpp
// compile with: /clr
using namespace System;
using namespace Microsoft::Win32;
int main()
{
// The second OpenSubKey argument indicates that
// the subkey should be writable.
RegistryKey^ rk;
rk = Registry::CurrentUser->OpenSubKey("Software", true);
if (!rk)
{
Console::WriteLine("Failed to open CurrentUser/Software key");
return -1;
}
RegistryKey^ nk = rk->CreateSubKey("NewRegKey");
if (!nk)
{
Console::WriteLine("Failed to create 'NewRegKey'");
return -1;
}
String^ newValue = "NewValue";
try
{
nk->SetValue("NewKey", newValue);
nk->SetValue("NewKey2", 44);
}
catch (Exception^)
{
Console::WriteLine("Failed to set new values in 'NewRegKey'");
return -1;
}
Console::WriteLine("New key created.");
Console::Write("Use REGEDIT.EXE to verify ");
Console::WriteLine("'CURRENTUSER/Software/NewRegKey'\n");
return 0;
}
Spooner
Please post your question in:
http://forums.microsoft.com/msdn/ShowForum.aspx ForumID=29
Regards,
Vikram
RobEdwards
Thanks for reply my question. The project is about to add registry into window 98 so that when we insert portable device into computer, it won't appear "Add new hardware wizard" but it can detect it directly. How can i do that thank you.
Wong
rcangus
The sample that I gave you is in Visual C++/CLI... It is the new approach or extension of C++ that targets the .net framework 2...
If you want to try it out check...
http://lab.msdn.microsoft.com/express/visualc/default.aspx
cheers,
Paul June A. Domag
MaurizioPe
Erm... thanks for the info, does visual C++ is written in same way Because School project is written in Visual C++ with object oriented. thank you...
Wong