Reading Value from Registry Key.

Hi, I'm using VB2005 (still) and working in WinForms. I have a question that may be a little off topic on the NET side of the house, but its still VB related, so I'll ask it anyway in hope that someone can help.

I need to read a Registry Key from a Windows XP machine. Let's say I wanted to read the type of Default Printer that a computer is using. I would need to read something like:

HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device -- (I think this is where Windows keeps the "Default" printer from the Control Panel).

How would I do that?

Here's the part that is maybe off topic here...and very tricky!!!

I would like to add that code to an MS Word Document in the Macros section, where you can code in VB and have the document print the name of Default printer when it prints out a print job.

So, this is a two step question:

1). How would I read out of that Registry in VB.NET and print it out to say the console?
2). How would I add that code to the Macro's area of an MS Word Document and get the Word document to print out the name of the printer it used when it prints a print job?

Thank you,
Fulano
Mr_FulanoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mr_FulanoAuthor Commented:
CodeCruiser...you're just too good!!! Wow, is there anything you don't know how to program?

Thanks for the help,
Fulano
0
Mr_FulanoAuthor Commented:
Great help!!! Thank you.
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

CodeCruiserCommented:
Fulano,
EE provides a very good opportunity to learn new things which I dont usually do otherwise.

Thanks for the compliment :-)
0
CodeCruiserCommented:
By the way, just realized that I pasted the same link twice for VB.NET!
0
Mr_FulanoAuthor Commented:
That's OK, I usually need to read things more than once to understand them anyway...: )
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.