Visual Studio Hacks [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Visual Studio Hacks [Electronic resources] - نسخه متنی

Andrew Lockhart

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید







Hack 30. Hack the Registry

Visual Studio has some settings that you can
get to only through the registry. You'll need to be
careful, but you can do some incredible things in there.

The Visual Studio registry contains a host
of settings. Some of these settings can be accessed from the normal
Tool Options dialog; others can be edited with Visual
Studio power toys; some can be edited only directly in the registry.
In this hack, you are going to learn how to make these changes, how
to use an alternative registry, and how to move these settings from
machine to machine.


4.8.1. Registry Settings


Visual Studio stores most settings in two
different places in the registry. The first section is located under
HKEY_CURRENT_USER/Software/Microsoft/VisualStudio/<7.1>
and stores all of the user-specific settings. This section
includes settings for the various editors, external tools, source
control, and just about everything located in Tools
Options.

The other place that Visual Studio stores settings is under
HKEY_LOCAL_MACHINE/Software/Microsoft/VisualStudio/<7.1>.
The systemwide settings are stored in this
location. Any changes here will affect all users of the system as
opposed to just your own settings.

Between these two locations, you can modify just about any setting in
Visual Studio. Most of the registry keys and values are human
readable. Figure 4-17 shows an example of some of
the settings that can be modified in the registry.


Figure 4-17. Registry Editor

I am not going to cover individual registry settings in this hack,
since we cover those in other hacks. Many of the settings that once
had to be edited directly through the registry, like the recent file
and projects list [Hack #13] and custom file
extensions [Hack #29], can now be
edited using a power toy like VSTweak.

Some settings can still be edited only through the registry, and if
there is something you can't find in any of the
power toys or on the Tools Options screen, then the next
place to look is the registry.


4.8.2. Moving Registry Settings


Moving registry settings is
a fairly simple procedure, but one that can often be fraught with
danger. A good rule of thumb to follow is to move only settings that
you understand. Your instinct might be to copy the entire settings
tree, and while this might work, it can also cause some issues
(especially with recent file and project lists, since those file and
projects might not be in the same place and could cause huge delays
when opening Visual Studio).

To move registry settings from one machine to another, all you need
to do is open regedit (Start Run
type regedit) on your machine, find
the group of settings you want to copy, then right-click on the
parent key and choose Export. This is shown in Figure 4-18.


Figure 4-18. Registry Editor dialogExport tab

After clicking Export, you will be prompted for a place to save a
.reg file. After saving this file, you can move
it to another machinewhen you double-click on the file on the
new machine, you will be prompted to confirm that you want to add
this information to your registry. After clicking Yes, you will see
another prompt confirming that the information has been entered into
your registry. Moving registry settings between computers using this
method is relatively easy and is the only way to move settings like
Font and Colors or editor settings between systems (unless you are
using Visual Studio 2005 [Hack #31] ).


4.8.3. Use an Alternate Registry Tree


We authors always encourage
our readers to back up their registry before playing with itif
the wrong things are changed in the registry, Visual Studio
won't start or won't work properly.
Sometimes a reinstallation of Visual Studio is necessary, which we
all know uses hours of your time that you won't ever
get back.

Visual Studio includes an alternative to backing up your registry.
You can actually switch the registry that Visual Studio uses! This
way you can make a copy of the current registry, tell Visual Studio
to use that registry, hack the registry settings to your
heart's content, and then if you have any issues,
just switch back to the old registry location.

The process for switching to an alternate registry is as follows:

Make a copy of the current registry. Using
regedit, go to
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\<7.1>,
right-click on the folder, and export the entire key to a
.reg file.

Open the .reg file in a text editor and replace
all instances of
"\7.1"
with
"\7.1Hacks".
(7.1 being the version of Visual Studio
that you are using.)

Double-click on the .reg file, which will load
all the keys into your registry.

If you also want to move your user-specific settings, you should
repeat the preceding process for the key located at
HKEY_CURRENT_USER\SOFTWARE\Microsoft\VisualStudio\<7.1>.
You don't have to copy over your user settings
though; when you start Visual Studio with the new registry tree, it
will create a new set for you automatically.

After creating the new registry, you next need to tell Visual Studio
to use the new registry by using the /rootsuffix
switch. Go to Start Run and type
devenv.exe /rootstuffix
Hacksthis will launch Visual Studio
using the new registry tree. Notice that you should type only
Hacks and not 7.1Hacks,
since Hacks is the suffix that you are adding onto the end of the
current key.

When Visual Studio opens, it will be running using the new registry,
and you can play around as much as you want and switch back by simply
closing Visual Studio and opening it without using the switch. If you
wanted to switch to a different registry for an extended amount of
time, you could always create a shortcut that includes the
switch.


/ 172