Windows registry

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.
[165 byte] By [SingHee] at [2008-1-26]
# 1
Hi,

Please post your question in:
http://forums.microsoft.com/msdn/ShowForum.aspx?ForumID=29

Regards,
Vikram

Vikram at 2007-8-21 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 2
Hi Vikram,
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

SingHee at 2007-8-21 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 3

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;
}

Hope this gets you started...
next time post on the C++ Forum...
http://forums.microsoft.com/msdn/ShowForum.aspx?ForumID=29

cheers,


Paul June A. Domag

PaulDomag at 2007-8-21 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 4

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

SingHee at 2007-8-21 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 5
Hi,
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
PaulDomag at 2007-8-21 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...

.NET Development

Site Classified