Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Ask the Doc Detective: Read from the Registry of VB .NET Applications and More

Questions and answers from Microsoft documentation experts.


advertisement
inding what you need in the Microsoft® Visual Studio .NET documentation, which has over 45,000 topics, can be a daunting task. The Doc Detective is here to help, utilizing his investigative skills to probe the depths of the documentation.

Can't find what you're looking for? Just ask—if it's in there, I'll find it for you; if it isn't, I'll let you know that as well (and tell you where else you might go to find it).

Have a question for the Doc? Send your questions for future columns to me at docdetec@microsoft.com.

Dear Doc Detective,

I'm trying to use the GetPrivateProfileString API call to read from the registry in my VB .NET application. I found a code example in the topic "Upgrade Recommendation: Adjust Data Types for Win32 APIs," but I can't seem to get it to work. What am I doing wrong?

—Aggravated in Allentown

Dear Aggravated,

Well, it appears to the Doc that you are traveling down the wrong path. The topic that you refer to is intended only for existing VB6 code that you are moving to .NET; it is not the recommended way of coding in .NET. The .NET Framework provides much better support for working with the registry in managed code via the Registry class, so GetPrivateProfileString and most other API calls are no longer necessary.

For an example of accessing the registry in VB .NET, see the topic: "Code: Reading Data from the Registry (Visual Basic)."

If you are trying to use the registry to store user settings or application information, instead of using the registry you might want to consider using dynamic properties and storing them in the app.config file. The article "Creating Your Own Dynamic Properties and Preserve Property Settings in Visual Basic .NET" discusses this and shows you how to do it.

—Doc D




Dear Doc Detective,

I read somewhere that you can create shaped forms in Visual Studio .NET. I've searched the docs to no avail—was I dreaming? If not, where can I find info on shaped forms?

- Rectangular in Reno

Dear Rectangular,

You're not dreaming. You can indeed create shaped forms and controls, but unfortunately this didn't make it into the documentation. Don't despair though—there is an excellent whitepaper available in the MSDN Library called "Shaped Windows Forms and Controls in Visual Studio .NET" that should get you up and running. Although personally the Doc thinks that "shaped forms" is a misnomer—after all, a rectangle is a shape too.

—Doctor D




Dear Doc Detective,

I am working on a Web application. In the old ASP days I could use Session, Response, Request, and similar objects in my page. I can't find any documentation on those objects for ASP.NET, though. I did find documentation on something that sounds similar—HttpSessionState, HttpResponse, etc. Are those the same thing?

—Web-footed in Washington

Dear Web-footed,

This is a pretty common question. The short answer to your question is: sort of. All those intrinsic ASP objects you know and love—Session, Request, Application, and all their cousins and their sisters and their aunts, are still available to you in ASP.NET as properties of the page or control you are working with. What's a little confusing is that the intrinsic objects are static instances of the corresponding Httpxxxx classes. In the documentation for the Httpxxx classes, this is usually (alas, not always!) noted in the fine print, aka the Remarks section. For instance, in the Remarks section of the HttpRequest Class topic, it says "The methods and properties of the HttpRequest class are exposed through the Request property of the HttpApplication, HttpContext, Page, and UserControl classes." It doesn't quite say "You can use members of the HttpRequest class via the page's Request property," but that's what it's meant to say.

In fact, you don't ever use the Httpxxx classes directly. They're public classes only so that their members are exposed via the intrinsic objects such as Request and Session. Here's a list of the intrinsic objects and the classes they map to:

Response ==> HttpResponse Request ==> HttpRequest Context ==> HttpContext Server ==> HttpServerUtility Application ==> HttpApplicationState Session ==> HttpSessionState Trace ==> TraceContext


If you want to know what you can do with the Session object, for example, look in the topic, "HttpSessionState Members."

Happy (intrinsic) Webbing,

—the Doc




Dear Doc Detective,

The .exe file from my project has a boring icon in Windows Explorer. How do I assign a custom icon to the .exe file? Are there any tools in Visual Studio for making icons? Will the custom icon appear on the Start menu when I deploy my application?

—Bored in Baltimore

Dear Bored,

Icon help you here! You are only a couple of clicks away from a custom icon for your .exe file. The Application Icon property is described in the topic "Build, Common Properties,

Property Pages Dialog Box."

You can use an icon you've created in any paint package. Visual Studio .NET also ships with many icons; you can find those in the Common7\Graphics\icons folder of your Visual Studio .NET installation. You can also create icons right in Visual Studio .NET, as described in the topic "Creating a New Bitmap or Other Image."

To make the icon appear on the Start menu, see the topic "Adding and Removing Icons."

—Doc Detective

Doc's Doc Tip of the Day
If you typically use only one programming language, you can filter topics so that they show examples in only that language. Click the Language Filter button at the top of a topic (it looks like a little funnel) and select your favorite language—voila! All the examples in other languages disappear from view.

Found a topic in Help that doesn't help? Tell the Visual Studio documentation team about it at vsdocs@microsoft.com .

Here's a list of URLs that contain information related to the questions and answers in this month's column.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbconupgraderecommendationadjustdatatypesforwin32apis.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vbcode/html/vbtskcodeexamplereadingdatafromregistry.asp

http://msdn.microsoft.com/library/en-us/dv_vstechart/html/vbtchCreateYourOwnDynamicPropertiesPreservePropertySettingsInVisualBasicNET.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchshapedwindowsformscontrolsinvisualstudionet.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWebSessionStateHttpSessionStateMembersTopic.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsintro7/html/vxurfBuildTab-ProjectPropertiesPage.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcresed/html/_Creating_a_New_Bitmap_or_other_graphic_resource.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsintro7/html/vxtskAddingRemovingIcons.asp



   
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date