Traitée Windows registry

  • vendredi 29 avril 2005 04:04
     
     
    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.

Toutes les réponses

  • vendredi 29 avril 2005 06:31
     
     Traitée
    Hi,

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

    Regards,
    Vikram
  • vendredi 29 avril 2005 07:22
     
     
    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
  • vendredi 29 avril 2005 14:40
     
     Traitée

    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


  • samedi 30 avril 2005 00:21
     
     

    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

  • samedi 30 avril 2005 10:03
     
     Traitée
    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