Visual Basic Q&A

As a software engineer, I focus on .NET, especially asp.net, C#, WCF and so on, and I am also very interested in Search Engine Optimization.

Entries for the ‘configuration’ Category

Keywords to search .NET-related Knowledge Base articles

Symptoms
The Microsoft Knowledge Base is categorized by keywords. The keywords help to refine the search criteria. This article lists the keywords that are used as metadata for .NET related Knowledge Base articles. The following .NET-related areas are included in this article: ADO.NETASP.NETAssembliesBCL (Base Class Libraries)C#C++COM InteropCommon Language RuntimeDebuggingDeploymentEnterprise ServicesGDI+LocalizationMobile Controls.NET ClassesP-Invoke (Platform Invoke)RemotingSecurityVisual Basic .NETVisual Studio .NETWindows FormsWeb Services
Resolution
Each Knowledge Base article may contain one or more product-specific keywords (named KBKeyword) that put the article in the appropriate category. Some of the Knowledge Base keywords are composed of the resulting concatenation of keywords. For example, you can find all the ASP.NET and Data Binding issue articles by using the kbASPNET kbDataBinding keyword combination in your search criteria. The following tables list the topics that are related to .NET in the Knowledge Base, including a link to the related support centers (where available) where you can browse the Microsoft Knowledge base by topic, and the corresponding Knowledge Base keywords:ADO.NETADO.NET Support Center(http://support.microsoft.com/ph/548)

+—————————————————————————–+|FOCUS|KEYWORD COMBINATIONS|+———————————-+——————————————+| All ADO.NET related articles| kbADONET|+———————————-+——————————————+| Connection Pooling| kbADONET kbConnectionPooling|+———————————-+——————————————+| DataBinding| kbADONET kbDataBinding|+———————————-+——————————————+| DataSet issues| kbADONET kbSystemData kbDataSet|+———————————-+——————————————+| EvaluateExpression issue| kbADONET kbSystemData|+———————————-+——————————————+| Interop with native ADO| kbADONET kbInterop kbADO|+———————————-+——————————————+| OleDb issues| kbADONET kbOleDb|+———————————-+——————————————+| Oracle| kbADONET kbOracle|+———————————-+——————————————+| Performance| kbADONET kbPerformance|+———————————-+——————————————+| SqlClient issues| kbADONET kbSqlClient|+———————————-+——————————————+| SqlDataAdapter issues| kbADONET kbSystemData kbSqlClient||| kbSqlDataAdapter|+—————————————————————————–+ASP.NETASP.NET Support Center(http://support.microsoft.com/ph/1249)

+—————————————————————————–+|FOCUS|KEYWORD COMBINATIONS|+———————————-+——————————————+| All ASP.NET related articles| kbASPNET|+———————————-+——————————————+| All ASP.NET Enterprise Services| kbASPNET kbEntServices|| articles||+———————————-+——————————————+| All ASP.NET Data access related| kbASPNET kbADONET|| articles||+———————————-+——————————————+| Caching| kbASPNET kbCaching|+———————————-+——————————————+| Configuration| kbASPNET kbConfig|+———————————-+——————————————+| Connectivity| kbASPNET kbConnectivity|+———————————-+——————————————+| Cookieless Sessions| kbState kbCookie|+———————————-+——————————————+| DataBinding| kbASPNET kbDataBinding|+———————————-+——————————————+| Debugging| kbASPNET kbDebug|+———————————-+——————————————+| Deployment| kbASPNET kbDeployment|+———————————-+——————————————+| HttpRuntime| kbASPNET kbHttpRuntime|+———————————-+——————————————+| Migration| kbASPNET kbMigration|+———————————-+——————————————+| Navigation| kbASPNET kbNavigation|+———————————-+——————————————+| Page/Web Form| kbWebForms|+———————————-+——————————————+| Server Controls| kbASPNET kbServerControls|+———————————-+——————————————+| State Management| kbASPNET kbState|+———————————-+——————————————+| Validation| kbASPNET kbValidation|+———————————-+——————————————+| Web Form| kbASPNET kbWebForm|+—————————————————————————–+Assemblies.NET Framework Support Center(http://support.microsoft.com/netframe11)

+—————————————————————————–+|FOCUS|KEYWORD|+———————————-+——————————————+| All Assemblies related articles| kbAssemblies|+—————————————————————————–+BCL (Base Class Libraries)Class Libraries in the .NET Framework Support Center (http://support.microsoft.com/netframe11?sid=128)

+—————————————————————————–+|FOCUS|KEYWORD|+———————————-+——————————————+| All Base Class Library related| kbBCL|| articles||+—————————————————————————–+C#Visual C# .NET Supoprt Center(http://support.microsoft.com/ph/3040)

+—————————————————————————–+|FOCUS|KEYWORD COMBINATIONS|+———————————-+——————————————+| Compiler related issues| kbCompiler|+———————————-+——————————————+| Language related issues| kbLangC|+———————————-+——————————————+| Documentation/Samples| kbDoc or kbSample|+———————————-+——————————————+| Project/Build System| kbBuilder|+—————————————————————————–+C++Visual C++ .NET Supoprt Center(http://support.microsoft.com/vcnet)

+—————————————————————————–+|FOCUS|KEYWORD COMBINATIONS|+———————————-+——————————————+| ATL| kbATL|+———————————-+——————————————+| ATL Server| kbATLServer|+———————————-+——————————————+| Attributes| kbNativeAttributes|+———————————-+——————————————+| Compiler| kbCompiler|+———————————-+——————————————+| CRT| kbCRT|+———————————-+——————————————+| Designers| kbDesigner|+———————————-+——————————————+| Documentation/Samples| kbDocs or kbSample|+———————————-+——————————————+| Linker| kbLinker|+———————————-+——————————————+| MFC| kbMFC|+———————————-+——————————————+| Project/Build System| kbBuilder|+———————————-+——————————————+| STL| kbSTL|+—————————————————————————–+COM InteropCommon Language Runtime in the .NET Framework Support Center (http://support.microsoft.com/netframe11?sid=122)

+—————————————————————————–+|FOCUS|KEYWORD COMBINATIONS|+———————————-+——————————————+| All COM Interop related articles | kbCOMInterop|+———————————-+——————————————+| Data Marshaling| kbCOMInterop kbMarshal|+———————————-+——————————————+| Events| kbCOMInterop kbEvent|+———————————-+——————————————+| Threading| kbCOMInterop kbThread|+—————————————————————————–+Common Language RuntimeCommon Language Runtime in the .NET Framework Support Center(http://support.microsoft.com/netframe11?sid=122)

+—————————————————————————–+|FOCUS|KEYWORD COMBINATIONS|+———————————-+——————————————+| All common language runtime| kbCLR|| related articles||+———————————-+——————————————+| Component Model| kbCLR kbCompModel|+———————————-+——————————————+| Garbage Collector| kbCLR kbGarbageCollect|+———————————-+——————————————+| JIT Compiler/IL| kbCLR kbJIT|+———————————-+——————————————+| Profiling| kbCLR kbPerformanceTool|+—————————————————————————–+DebuggingDebugging in the .NET Framework Support Center(http://support.microsoft.com/netframe11?sid=262)

+—————————————————————————–+|FOCUS|KEYWORD COMBINATIONS|+———————————-+——————————————+| All Debugging related articles| kbDebug|+———————————-+——————————————+| common language runtime| kbDebug kbCLR|+———————————-+——————————————+| Configuration| kbDebug kbConfig|+———————————-+——————————————+| Mixed (Native/Managed)| kbDebug kbNativeAttributes kbManaged|+———————————-+——————————————+| Native| kbDebug kbNativeAttributes|+———————————-+——————————————+| Remote| kbDebug kbRemoteProg|+———————————-+——————————————+| Script| kbDebug kbScript|+———————————-+——————————————+| T-SQL| kbDebug kbTSQL|+—————————————————————————–+Deployment.NET Framework Support Center(http://support.microsoft.com/netframe11)

+—————————————————————————–+|FOCUS|KEYWORD|+———————————-+——————————————+| All Deployment related articles| kbDeployment|+—————————————————————————–+Enterprise ServicesEnterprise Services in the .NET Framework Support Center(http://support.microsoft.com/netframe11?sid=115)

+—————————————————————————–+|FOCUS|KEYWORD|+———————————-+——————————————+| All Enterprise Services related| kbEntServices|| articles||+—————————————————————————–+GDI+.NET Framework Support Center(http://support.microsoft.com/netframe11)

+—————————————————————————–+|FOCUS|KEYWORD COMBINATIONS|+———————————-+——————————————+| All Drawing related articles| kbDrawing|+———————————-+——————————————+| Design| kbDrawing kbDesign|+———————————-+——————————————+| Imaging| kbDrawing kbgdiimaging|+———————————-+——————————————+| Metafiles| kbDrawing kbMetafile|+———————————-+——————————————+| Performance| kbDrawing kbPerformance|+———————————-+——————————————+| Printing| kbDrawing kbPrint|+———————————-+——————————————+| Text/Fonts| kbDrawing kbgditext or kbDrawing kbFont|+———————————-+——————————————+| Transforms/Coordinate Spaces| kbDrawing kbgdiptransform|+———————————-+——————————————+| Vector Graphics| kbDrawing kbgdivector|+—————————————————————————–+Localization

+—————————————————————————–+|FOCUS|KEYWORD|+———————————-+——————————————+| All Localization related| kbLocalization|| articles||+—————————————————————————–+Mobile Controls.NET Framework Support Center(http://support.microsoft.com/netframe11)

+—————————————————————————–+|FOCUS|KEYWORD|+———————————-+——————————————+| All Mobile Controls related| kbCtrl|| articles||+—————————————————————————–+.NET Classes.NET Framework Support Center(http://support.microsoft.com/netframe11)

+—————————————————————————–+|FOCUS|KEYWORD|+———————————-+——————————————+| All .NET Class related articles| kbNETClasses|+—————————————————————————–+P-Invoke (Platform Invoke).NET Framework Support Center(http://support.microsoft.com/netframe11)

+—————————————————————————–+|FOCUS|KEYWORD|+———————————-+——————————————+| All P-Invoke related articles| kbPInvoke|+—————————————————————————–+RemotingRemoting in the .NET Framework Web Services Support Center(http://support.microsoft.com/netframe11?sid=100)

+—————————————————————————–+|FOCUS|KEYWORD COMBINATIONS|+———————————-+——————————————+| All Remoting related articles| kbRemoting|+———————————-+——————————————+| Channels| kbRemoting kbChannels|+———————————-+——————————————+| HTTP| kbRemoting kbHttp|+———————————-+——————————————+| TCP| kbRemoting kbTunneling|+———————————-+——————————————+| Connectivity| kbRemoting kbConnectivity|+———————————-+——————————————+| Delegates/Events| kbRemoting kbEvent|+—————————————————————————–+SecuritySecurity in the .NET Framework Support Center(http://support.microsoft.com/netframe11?sid=200)

+—————————————————————————–+|FOCUS|KEYWORD|+———————————-+——————————————+| All Security related articles| kbSecurity|+—————————————————————————–+Visual Basic .NETVisual Basic .NET Support Center(http://support.microsoft.com/vbnet2003)

+—————————————————————————–+|FOCUS|KEYWORD COMBINATIONS|+———————————-+——————————————+| All Visual Basic .NET related| kbVBNET|| articles||+———————————-+——————————————+| Compiler| kbVBNET kbCompiler|+———————————-+——————————————+| Documentation Bugs| kbVBNET kbDocumentation|+———————————-+——————————————+| Migration| kbVBNET kbMigration|+———————————-+——————————————+| Performance| kbVBNET kbPerformance|| (language, not related to IDE)||+———————————-+——————————————+| Samples| kbVBNET kbSamples|+———————————-+——————————————+| Language (including inheritance, | kbVBNET kbLanguage|| syntax, and others)||+—————————————————————————–+Visual Studio .NETVisual Studio .NET Support Center(http://support.microsoft.com/vsnet2003)

+—————————————————————————–+|FOCUS|KEYWORD COMBINATIONS|+———————————-+——————————————+| All Visual Studio .NET related| kbVSSearch|| articles||+———————————-+——————————————+| Admin| kbVSSearch kbAdmin|+———————————-+——————————————+| Deployment| kbVSSearch kbDeployment|+———————————-+——————————————+| Performance|kbVSSearch kbPerformance|| (IDE including project/build)||+———————————-+——————————————+| Project (including build,| kbVSSearch kbProject|| References, and others)||+———————————-+——————————————+| IDE| kbVSSearch kbIDE|| (such as windows and wizards)||+———————————-+——————————————+| Documentation Bugs| kbVSSearch kbDocumentation|+———————————-+——————————————+| Setup Specific| kbVSSearch kbSetup|+———————————-+——————————————+| Setup Bug| kbVSSearch kbSetup kbBug|+—————————————————————————–+Windows FormsWindows Forms Support Center(http://support.microsoft.com/netframe11?sid=133)

+—————————————————————————–+|FOCUS|KEYWORD COMBINATIONS|+———————————-+——————————————+| All Windows Forms related| kbWindowsForms|| articles||+———————————-+——————————————+| Controls| kbWindowsForms kbCtrl|+———————————-+——————————————+| Designer| kbWindowsForms kbDesigner|+———————————-+——————————————+| Events| kbWindowsForms kbEvent|+———————————-+——————————————+| Forms| kbWindowsForms kbForms|+———————————-+——————————————+| MDI| kbWindowsForms kbForms kbMDI|+———————————-+——————————————+| Menus| kbWindowsForms kbForms kbMenu|+—————————————————————————–+Web Services.NET Framework Support Center(http://support.microsoft.com/netframe11)

+—————————————————————————–+|FOCUS|KEYWORD COMBINATIONS|+———————————-+——————————————+| All Web Service related articles | kbNetFrameWebServ|+———————————-+——————————————+| Client Proxies| kbNetFrameWebServ kbClient|+———————————-+——————————————+| Discovery| kbNetFrameWebServ kbDiscovery|+—————————————————————————–+

INFO: VB6 Readme: Part 6 Wizard Issues

Symptoms
The information below includes the documentation and workarounds for VisualBasic 6.0. This information can also be found in the README.htm file thatships with Visual Basic 6.0 on the Visual Basic 6.0 CD-ROM. Please see theREFERENCES section of this article for a list of the Microsoft KnowledgeBase articles relating to the Visual Basic 6.0 readme.
Following is a list of all parts of the readme file:
Part 1.Important Issues Please Read First!
Part 2.Data Access Issues and DataBinding Tips.
Part 3.Control Issues.
Part 4.Language Issues.
Part 5.Samples Issues.
Part 6.Wizard Issues.
Part 7.Error Message Issues.
Part 8.WebClass Designer Issues.
Part 9.DHTML Page Designer Issues.
Part 10. Extensibility Issues.
Part 11. Miscellaneous Issues.
Part 12. Microsoft Transaction Server (MTS) Issues.
Part 13. Dictionary Object.
Part 14. Visual Component Manager.
Part 15. Application Performance Manager.
Resolution
Package and Deployment Wizard (PDW):Automatically Picks Up Files From Redist DirectoryA new feature of the Package and Deployment Wizard is its ability pick upfiles from the Redist folder. An example of how the feature is used wouldfollow the steps below:You have created an application that is ready for packaging.The application depends on a certain system file “MySysFile.dll” which,until recently, has been a stand-alone file. But now a recent systemupdate has made that file dependent on other files to function properly.However, a stand-alone version of the system file is also supplied.To simplify setups, you place that stand-alone version into the Redistfolder.When creating your deployment package, you navigate to the system fileto instruct the wizard that the system file should be included.Instead of picking up the system file (which is dependent on otherfiles), the Package and Deployment Wizard will pick up the stand-aloneversion that is in the Redist directory.
By default, no files are placed in the redist folder.
Package and Deployment Wizard Has [Do Not Redist] SectionA new section has been added to the Package and Deployment VB6Dep.ini file:[Do Not Redist]
Two kinds of files are listed under the new section:Files that are not needed at run-time. For example, ActiveX designersoften require two file references, one for design-time, and one for run-time. Since the design-time reference is not needed, it is listed in thesection and is not included in the package.Files that cannot be redistributed by the Package and Deployment Wizard.Some dependent files are not installed by Visual Basic, but must beinstalled by another component. For example, the following files areinstalled by Internet Explorer 4.x: Shdocvw.dll and Mshtml.dll.
Package and Deployment Wizard: In Silent Mode the NotificationWindow May Not Be First in the Window Z-orderWith Visual Basic, it is possible to run the Package and Deployment Wizardin silent mode from a command prompt. When doing so, you can also set apath for logging the wizard’s output (/l ). With the path set, the wizardwill create a log of events. If you do not use the argument, the wizardwill instead display a dialog box to notify you of the wizard’s completion.However, the window is not always obvious because it may be underneathother windows. In order to see it, you may need to close or minimize allother windows.
For more information, search online for “running as a stand-alone” inVisual Basic Concepts in the MSDN Library Visual Studio 6.0 documentation.
Package and Deployment Wizard: Command Line Mode Argument Added forSpecifying Executable PathAn argument has been added to the command line mode of the Package andDeployment Wizard. The argument is shown in the table below:

ArgumentDescription/e pathUse the argument to set the path for the project’sexecutable file if it is different from the project’spath. The argument allows the command line mode to be used in a multi-developerenvironment where a computer is dedicated to compiling the project andcreating the package.
For more information, search online with Package and Deployment Wizardselected, for running as a stand-alone in the MSDN Library Visual Studio6.0 documentation.
Package and Deployment Wizard: Manually Add User Control License FilesWhen creating a package for a user control that requires a license key, thelicense file (.vbl) is not automatically included. Instead, you must addthe file manually.
When you are at the dialog titled “Package and Deployment Wizard IncludedFiles,” click the Add button and search for the appropriate .vbl file.
Package and Deployment Wizard: Steps in the Web Deployment ProcessWhen you post an Internet package to a Web server using the Package andDeployment Wizard, the wizard uses a technology known as WebPost to copyyour package to the server and process it appropriately. These are thesteps that the WebPost process goes through when processing your .cab:It extracts the .cab file into a temporary directory.It locates the .inf file for the .cab file.Based on the contents of the .inf file, the WebPost process installsapplication files (based on the RInstallApplicationFiles section of the.inf file), installs system files (based on the RiinstallSystemFilessection), and installs shared files (based on the RInstallSharedFilessection). In the process, it registers any necessary files.NOTE: The DefaultInstall section of the .inf file is not run, because theinstructions it contains often require user input. The WebPost process alsodoes not create a virtual directory for your application, if one isrequired; directories must be set up in advance.
Package and Deployment Wizard: Web Deployment Tips for HTTP or FTP ProtocolIf the .cab file you are attempting to deploy to a Web server is copiedto the server but is not unpacked, make sure you included the .cab fileon the Items to Deploy screen, and that you used HTTP Post as theprotocol on the Web Publishing Site screen. In addition, you must havechecked the Unpack and Install Server-Side Cab check box on the WebPublishing Site screen. If you did not, try re-deploying your packageagain with this option selected.
NOTE: Cab unpacking is supported by Posting Acceptor 2.0 running on IIS4.0. If you receive an error saying that the Web server you selecteddoes not support the service provider you selected, there are severalthings you can do to try to fix this problem:If you are using the HTTP Post protocol, make sure that PostingAcceptor is installed on your Web server. If you are running IIS4.0, install Posting Acceptor 2.0. If you are running IIS 3.0,install Posting Acceptor 1.0. Cab unpacking is not supported byPosting Acceptor 1.0.Ensure that your URL is correct. If you are using HTTP Post,ensure that your URL begins with “http://”. If you are using FTP,ensure that your URL begins with “ftp://”.If you are uploading to a server location that has PostingAcceptor 1.0 installed, you cannot select the option to unpack andinstall your cabinet files when you deploy your package using thewizard. If you receive an error C0042115 that the query stringINSTALL is invalid, check your server configuration to determinewhat version of posting acceptor is installed. If it is version1.x, deploy your cab again, making sure to deselect the Unpack andInstall Server-Side Cab option.If you need to use the FTP protocol to post to a URL beginningwith “http://”, you may be able to resolve this error by adding thefollowing entry to the end of your Web server’s postinfo.asp file,usually located in the scripts directory on the Web server:[{02B5E1D1-8B7C-11D0-AD45-00AA00A219AA}]ServerName=” <%= Request.ServerVariables(“SERVER_NAME”) %>”MDAC installation requires DCOM95 to be installed. Setup programscreated with the Package and Deployment Wizard install the MicrosoftData Access Components (MDAC), which includes OLE DB, ADO and Jet,via the MDAC installer program: Mdac_typ.exe. This EXE requires thatthe machine being installed to have DCOM95 (or the newer DCOM98)installed on it.
If the MDAC intaller fails with a “DLL registration failed” message,this is because DCOM was not found on the machine. To restorefunctionality of existing data components, install DCOM95 and run theinstaller again.If you use the HTTP Post protocol and receive an error that you do nothave write access for the Web server, open the Internet Service Manageron the server computer, access the node for your Default Web Site(Console Root \ Internet Information Server \ machinename \ Default WebSite), choose Properties, select the Home Directory tab, and check theWrite check box.If your files are read-only when you try to post, you will receive anerror C0042116 announcing that processing has stopped. Change your fileattributes to proceed.Be aware that if you post a file to a directory where the same filealready exists, the file on the server will be overwritten and nowarning message will be displayed.If you use the FTP protocol and receive an error that access is denied,open the Internet Service Manager on the server computer, access thenode for your Default FTP Site (Console Root \ Internet InformationServer \ machinename \ Default FTP Site), choose Properties, select theHome Directory tab, and check the Write check box.If you use the FTP protocol and receive additional errors besides theone described in the previous bullet, make sure that you have properlyconfigured your FTP service on the Web server. To do so, start theMicrosoft Management Console (MMC), then follow these steps:Right-click on Default FTP Site and choose New Virtual Directory.Enter an alias to be used to access the virtual directory, thenclick Next.Enter the physical path of the directory to which to map thevirtual directory (for example, c:\inetpub\ftproot) then clickNext.Select the appropriate access permissions, making sure to allow writeaccess so that your deployments can proceed without errors, thenclick Finish.Right-click on Default FTP Site and choose Stop.Right-click on Default FTP Site and choose Start.
When you deploy to the FTP server using the Package and DeploymentWizard, use the site FTP://servername/alias where alias is the aliasyou assigned in step 2. Use the username “anonymous” and the password”me@somewhere” for anonymous login.
Package and Deployment Wizard: Start Menu Items: Run Option Not SupportedWhen creating a package for deployment, you can also create a Start menuitem. Although it is mentioned in the Help topic for the dialog box, theRun option is not supported.
System Configurations for WebPost’s Posting AcceptorWhen you deploy your packages to a Web server, the Package and DeploymentWizard uses a technology known as WebPost to move your files to the desiredlocation. WebPost consists of two main components:The Package and Deployment Wizard, which sends your content to aqualified site.A Posting Acceptor, located on the Web server, that enables the postingof content to an IIS server.There are multiple versions of Posting Acceptor available. You must makesure you install the correct version on your Web server based on yourmachine configuration. The following table lists the appropriateconfigurations:

Use thisif you are runningComments————————————————————————–Posting Acceptor 2.0Windows NT 4.0 with SP3Posting Acceptor 2.0IIS 4.0supports both contentposting and theunpacking of cabinet(.cab) files on theserver.Posting Acceptor1.0 Windows NT 4.0You cannot unpack .cabwith SP3with this versionIIS 3.0files of postingacceptor. Use this forcontent posting only.You can move yourfiles to the serverand then manuallyregister any necessaryfiles that would havebeen registered by the.cab process. NOTE: Posting Acceptor does not work on any platforms that are usingPersonal Web Server or Peer Web Server. You must use IIS. Steps forinstalling Microsoft Posting Acceptor 2.0 if you have Visual Studio orVisual Basic Enterprise Editions.Launch Visual Studio or Visual Basic setup from your installation CDs.When prompted to choose options to install, click Install ServerApplications and Tools, then click Next.Click Launch the BackOffice Installation Wizard, then click Install.Now select the radio button for Custom, then click Next. You will see the options to install and their sizes. Click Next.Select Microsoft Posting Acceptor 2.0.You can install Posting Acceptor 2.0 from the Deploy folder of VisualStudio installation CD number 2. Posting Acceptor 1.0 can be installed fromthe Microsoft Posting Acceptor Information Website. If you want to installPosting Acceptor 2.0 on a computer that already has the Windows NT OptionPack, you should first check to see if version 1.0 of the Posting Acceptoris already installed. If so, remove it before installing version 2.0. Todetermine if 1.0 is installed, select the NT Option Pack on the Add/RemovePrograms mechanism of the Control Panel. Click Add/Remove, then look forPosting Acceptor 1.0 among the components listed. You may find it underMicrosoft Site Server. If it is installed, remove it. You can then installversion 2.0 by running PASetup.exe.
Package and Deployment Wizard: Edit Setup.lst File If YouRebuild Cabs From Batch FileAfter creating a standard setup package using the Package and DeploymentWizard, you can manually recreate the setup files (Setup.exe, Setup.lst,and all .cab files) by running the batch file found in the in the Supportfolder. Doing this allows you to manually customize the package or torecreate a package without running the wizard again. Running the batch filewill copy setup.exe and setup.lst from the Support folder to the Packagefolder and will generate the cab file(s) in the Package folder. However,once the batch file is finished, setup.lst will not know how many .cabfiles were generated. Unless this problem is remedied, the setup programwill fail.
To remedy this situation, do the following:Before running the batch file, delete all .cab files in the Packagefolder.After running the batch file, count the number of cabs produced by thebatch operation.Open the Setup.lst file in the Package folder with a text editor. NOTE: There are two Setup.lst files. One is found in the Support folder. Thesecond is found outside the Support folder, in the Package folder wherethe .cab files are created. Be sure to open the Setup.lst file in thePackage folder.In the text editor, look for the following lines, which are at the topof the file):

[Bootstrap]SetupTitle=InstallSetupText=Copying Files, please stand by.CabFile=Projec1.CABSpawn=Setup1.exeUninstal=st6unst.exeTmpDir=msftqws.pdw After the last line (TmpDir=msftqws.pdw), insert the following linewhere N equals the number of cabs generated:

Cabs=N The Setup.lst should now be up to date, and the setup won’t fail.
Package And Deployment Wizard: Error 80042114If you are creating a package for Internet deployment and you get thefollowing error:

“Unexpected error 80042114 has occurred: The Web server you selecteddoes not indicate support for the service provider you selected. Do youwant to proceed anyway?”This error occurs because you have specified that your package should beposted to an FTP site using an HTTP URL. If you are certain that you haveaccess privileges to the web server, you can click “Yes” and the deploymentwill proceed.
To avoid this error in the future, when creating a package for deploymenton the same server, specify the site and its protocol. When you do so, thefollowing dialog box will appear:
“The specified URL and publishing method can be saved in the registry asa Web publishing site. This ensures that the URL and publishing methodare valid and saves you time in future deployments to this site. Do youwant to store this information as a Web publishing site?”
If you select “yes,” this saves the site information and you will no longerreceive the 80042114 error.
Package and Deployment Wizard: Use Mdac_typ.Cab and Mdac20.Cab toDistribute Data Access ComponentsWhen your Internet Package includes any of the following four files, thewizard will by default set these files to be downloaded from:
http://activex.microsoft.com/controls/vb6/mdac_typ.cab(http://activex.microsoft.com/controls/vb6/mdac_typ.cab)
MSDAOSP.dll
MSADO15.dll
MSADCF.dll
ODBC32.dll
Similarly, the wizard will, by default, set the following files to bedownloaded from:
http://activex.microsoft.com/controls/vb6/mdac20.cab(http://activex.microsoft.com/controls/vb6/mdac20.cab)
MSADOR15.dll
MSADCO.dll
In both cases, these defaults are indicated as the “Download from MicrosoftWeb site” option on the File Source screen. These cab files (mdac_typ.caband mdac20.cab) perform special handling that should not be attemptedmanually. In order to ensure that the proper handling takes place, yourInternet cab should not include these files but rather should reference thecabs. Therefore, you should never choose the “Include in this cab” optionfor any of these files. In addition, if you choose the “Download fromalternate Web site” option, you should be careful to specify cabs that arecopies of these cabs to ensure that the proper handling takes place.
Do not change the default settings for these files.
Package and Deployment Wizard: Manually Include .ASP and .HTM FilesFor IIS Applications When Using Standard SetupIf you use the Package and Deployment Wizard’s standard setup to deploy anIIS application, you must manually include any .asp or .htm files with thepackage. Add the files using the Include Files dialog box.
Package and Deployment Wizard: Bad Date and Time FormatsIn certain situations, the Package and Deployment Wizard will incorrectlywrite time and date information to the Setup.lst file. When this occurs,the setup will fail because the dates will be written in a form that thesetup.exe can’t read. The problem occurs when you create a deploymentpackage using the US version of Visual Basic on:A computer using the German version of Windows (NOTE: the German versionof Visual Basic will work correctly.)Any computer where the date separator isn’t either a forward slash (“/”)or a dash (“-”).To fix the bad formats:From the Start menu, open Control Panel.Click the Regional Settings icon.On the Date tab, change the Date separator to “/”.On the Time tab, change the Time separator to “:”.Run the Package and Deployment Wizard.Restore the date and time settings.
Package and Deployment Wizard: Unable to Run Setup.exe onFirst Windows 95 VersionAny setup package built with the wizard will not launch on certaininstallations of Windows 95 due to lack of support for an API in theoriginal version of the Oleaut32.dll. This failure will not occur on OSrelease 2 of Windows 95 or any versions of Windows NT 4.0 and later, andwill not occur if Microsoft Office 97 or Internet Explorer 3.0 or 4.0 hasbeen installed. Any installation of a Visual Basic 5.0 application willalso remedy the situation. You can also work around this failure by firstoverwriting the older version of Oleaut32.dll with the latest version. Besure to shut down all applications before attempting to manually updateOleaut32.dll.
Package and Deployment Wizard: Packaging ActiveX DocumentsThe Visual Basic 6.0 Package and Deployment Wizard can insert CODEBASE= andVERSION= information directly embedded into the .vbd file for your ActiveXDocument project. This eliminates the need for having the extra .htm filepreviously used to launch ActiveX Documents. The embedded informationallows Internet Explorer to read the .cab file name for your ActiveXDocument code and version information from the .vbd file and carry out theinstallation. You can now navigate directly to the .VBD file and your Userdocument code will download if necessary.
The same functionality was available for Visual Basic 5.0 setup using theSetCodeBase utility found on the Visual Basic Owners Area.
The following are some issues with Visual Basic 6.0 Package and DeploymentWizard generated setups for User documents:Internet Explorer 3.x. 4.0, and 4.01 cannot read the embeddedinformation in the VBD file. The wizard also generates an old (VB5)style .htm file. This .htm file can be used to launch ActiveX Documents.You must first modify the .htm file, however, since most of the code iscommented out. After removing the comments and an extra <A> tag (<ahref=xxxx.VBD>xxxxx.VBD</a>) from the top,from the top, the file will only be anOBJECT tag with the CLSID of your User document and some script code forWindow_OnLoad event.Internet Explorer 4.01 with Service Pack 1 and later will read thisinformation correctly from the .vbd file.

INFO: VB 6.0 Readme Part 15: Application Performance Explorer

Symptoms
The information below includes the documentation and workarounds for VisualBasic 6.0. This information can also be found in the README.htm file thatships with Visual Basic 6.0 on the Visual Basic 6.0 CD-ROM. Please see theREFERENCES section of this article for a list of the Microsoft KnowledgeBase articles relating to the Visual Basic 6.0 readme.
Following is a list of all parts of the readme file:

Part 1.Important Issues – Please Read First!Part 2.Data Access Issues and DataBinding TipsPart 3.Control IssuesPart 4.Language IssuesPart 5.Samples IssuesPart 6.Wizard IssuesPart 7.Error Message IssuesPart 8.WebClass Designer IssuesPart 9.DHTML Page Designer IssuesPart 10. Extensibility issuesPart 11. Miscellaneous IssuesPart 12. Microsoft Transaction Server (MTS) IssuesPart 13. Dictionary ObjectPart 14. Visual Component ManagerPart 15. Application Performance Manager
Resolution
Known Problems in Application Performance Explorer:
Configuring Remote Automation Security When Using Remote APE ComponentsIn order to use Remote Automation (RA) to communicate with remote APEcomponents, you may have to configure RA security using the RemoteAutomation Connection Manager (Racmgr32.exe).
To configure RA security:
Start Racmgr32.exe and click the Client Access tab.Select either “Allow All Remote Creates” or “Allow Remote Creates byKey”.If “Allow Remote Creates by Key” is selected, make sure the “AllowRemote Activation” check box is checked for each APE component.RA supports the following levels of authentication:

NameValueDescription———————————————————————Default0Use Network default.None1No authentication.Connect2Connection to the server is authenticated.Call3Authenticates only at the beginning of eachremote procedure call, when the serverreceives the request. Does not apply toconnection-based protocol sequences (thosethat start with the prefix “ncacn”).Packet4Verifies that all data received is from theexpected client.Packet5Verifies that none of the data transferredIntegritybetween client and server has beenmodified.Packet Privacy 6Verifies all other levels and encrypts theargument values of each remote procedurecall.
APE profiles are initially installed with an authentication level of 1(“None”) because Windows 95 supports only that level of authentication.However, if additional security is desired, the level of authentication ofa profile can be changed by modifying the profile collection file (theAemanagr.ini file) by using a text editor such as Notepad.
Each profile in the profile collection file begins with the name of theprofile within square brackets, such as [Peak performance, synchronous(CPU, Pool)]. The attributes of the profile follow, using the format<name>=<value> (such as “Task Duration=1″). To change the authenticationlevel, change the value of the “Authentication” attribute of the selectedprofile and save the file.
Compatibility Issues Between the Application Performance Explorer (APE)that Ships with Visual Studio 6.0 and the Version that Shipped with Visual
Basic 5.0There are known compatibility issues between the Application PerformanceExplorer (APE) that ships with Visual Studio 6.0 and the APE that shippedwith Visual Basic 5.0.
To avoid the compatibility issues, do one of the following:
Before installing Visual Studio 6.0 and APE on the computer that has theversion of APE shipped with VB 5, first uninstall APE from Visual Basic,and then install Visual Studio and APE.If you have installed Visual Studio 6.0 and APE on the same computerthat has the VB5 APE, uninstall the VB APE and then reinstall the VisualStudio APE.
Adjusting Default Settings To Use APE and MTSAfter installing the APETEST database onto your SQL Server, you must adjustsome of the default settings in order to use APE and MTS.
NOTE: If you haven’t already installed the APETEST database on your SQLServer, you should do that first. To learn how to install the APETESTdatabase, search for the topic “APE Database Setup Wizard” in MSDN LibraryVisual Studio 6.0.
To configure the APETEST database installation to work with MTS:
Start Microsoft SQL Enterprise Manager.In the Databases folder, right-click the APETEST database and clickEdit.Click the Options tab.Select the Truncated Log on Checkpoint check box and click OK.In the Databases folder, right-click the tempdb database and click Edit.Click Expand.In the Data Device box, select <new>.In the New Database Device dialog box, in the Name box, type tempdbData.In the Size (MB) box, type 10.Click Create Now, and finally click OK.Click Expand Now.Click Expand.In the Log Device box, select <new>.In the New Database Device dialog box, in the Name box, type tempdbLog.In the Size (MB) box, type 10.Click Create Now, and finally click OK.To configure the allowable number of user connections:
Start Microsoft SQL Enterprise Manager.Right-click the server and click Configure.For example, if your server is named CORONA, in the Server Manager childwindow, right-click CORONA and then click Configure.Click the Configuration tab.In the Configuration box, increase the number of user connections by atleast 15.
NOTE: If you are running APETEST on an established production databaseserver, you may not have access permission to adjust the current number ofuser connections. In this case, you should ask your database administratorto increase the number of current user connections by at least 15connections to support APE testing.
Application Performance Explorer Server-Side Setup May Generate ErrorWhile installing the APE server-side components, you may see an errorreferring to an incorrect version of OLEAUT32.dll. You may dismiss thiserror and continue with the installation.
However, this error message may indicate that the Microsoft TransactionServer Package was not installed correctly. To confirm that it wasinstalled correctly, run the Transaction Server Explorer and look for allinstalled MTS packages on your computer. Visual Studio APE Package shouldbe listed.
To install the package, AEMTSSVC.pkg, run the MTS Transaction ServerExplorer from the Start menu and install the package to the local computerusing the MTS Explorer.

INFO: Troubleshooting Error 429 When Automating Office Applications

Symptoms
When you use the New operator or CreateObject function in Microsoft Visual Basic to create an instance of a Microsoft Office application, you may get the following error message:

Run-time error ‘429′: ActiveX component can’t create objectThis error occurs when the requested Automation object could not be created by COM, and is therefore unavailable to Visual Basic. The error is typically seen on certain computers but not others.
This article provides some troubleshooting tips to help you diagnose and resolve common problems that are known to cause this error.
Resolution
Unlike some errors in Visual Basic, there is no one cause to an error 429. The problem happens because of an error in the application or system configuration, or a missing or damaged component. Finding the exact cause is a matter of eliminating possibilities. If you encounter this error on a client computer, there are a number of things you will need to check to isolate and resolve the error.
The items later give you some practical suggestions for troubleshooting this error when you work with Office Applications. Some of this information may also apply to non-Office COM servers as well, but this article assumes you are trying to automate Microsoft Office.
Checking the CodeThe first place to begin looking for the problem is in the code. Before you can troubleshoot the error, you need to know where the error occurs. Try to narrow it down to a single line of code.
When you find the code that is failing, try to do the following:
Make sure the code uses explicit object creation. Any problem is easier to spot and identify if the problem is narrowed to a single action. For example, do not do the following:

Application.Documents.Add ‘DON’T USE THIS!!
or:

Dim oWordApp As New Word.Application ‘DON’T USE THIS!!’… some other codeoWordApp.Documents.Add Both of these methods use implicit object creation. Microsoft Word is not started until the variable is called at least once. Since the variable could be called in different parts of the program, this could make the problem hard to localize. Also, it is not clear whether the problem is with creating the Application object or the Document object.
Instead, make explicit calls to create each object separately:

Dim oWordApp As Word.ApplicationDim oDoc As Word.DocumentSet oWordApp = CreateObject(“Word.Application”)’… some other codeSet oDoc = oWordApp.Documents.Add This makes the problem easier to isolate and makes the code more readable.When creating an instance of an Microsoft Office application, use CreateObject instead of New. CreateObject more closely maps to the creation process used by most Visual C++ clients, and allows for possible changes in the server’s CLSID between versions. CreateObject can be used with both early-bound and late-bound objects.Verify that the ProgID string passed to CreateObject is correct and that it is version independent (that is, use “Excel.Application” rather than “Excel.Application.8″). It could be that the system that is failing has an older or newer version of Microsoft Office than the version you specified in the ProgID.To aid in debugging applications that cannot be run in the IDE, use the Erl command to report the line number of the line that fails. For example, the following code will tell you which Automation object cannot be created (Word or Excel):

Dim oWord As Word.ApplicationDim oExcel As Excel.ApplicationOn Error Goto err_handler1: Set oWord = CreateObject(“Word.Application”)2: Set oExcel = CreateObject(“Excel.Application”)’ … some other codeerr_handler:MsgBox “The code failed at line ” & Erl, vbCritical Use a combination of message boxes and line numbers to track down the error.Try using late binding (that is, Dim oWordApp As Object). Early bound objects require their custom interfaces to be marshaled across process boundaries. If there is a problem marshaling a custom interface during CreateObject or New, you will get an error 429. A late bound object uses a system-defined interface (IDispatch) that does not require a custom proxy in order to be marshaled. Try using a late bound object to see if this makes a difference.
If the problem occurs only when the object is early-bound, the problem is with the server application, and can typically be corrected by reinstalling the application (see later).If you are automating from ASP or an MTS component, use CreateObject instead of Server.CreateObject(). Using Server.CreateObject will instantiate the Office application under the identity of an MTS package which is known to cause problems with Microsoft Office.
Checking the Automation ServerThe most common reasons for an error with CreateObject or New are problems with the server application itself. Typically, these problems are with the configuration or setup of the application. Here are some items to check:
Verify the Microsoft Office application you want to Automate is installed on the local computer, and make sure that you can start the application from the Start and then Run dialog box. If the program cannot be started manually, it will not work through automation.Re-register the application by typing the path to the server in the Start and then Run dialog box, and then append /RegServer to the end of the line. Press OK. This should silently run the application and re-register it as a COM server. If the problem is with a missing registry key, this will typically correct it.Check the LocalServer32 key under the CLSID for the application you want to Automate. Make sure it points to the correct location for the application, and make sure the path name is in a short path (DOS 8.3) format. While it is not a requirement that a server be registered using a short path name, long path names that include embedded spaces have been known to cause problems on some systems (see later).
To check the path key stored for the server, start the Windows Registry Editor by typing regedit in the Start and then Run dialog box. Navigate to the HKEY_CLASSES_ROOT\Clsid key. Under this key you will find the CLSIDs for the registered automation servers on the system. Using the values later, find the key that represents the Office application you want to Automate and check its LocalServer32 key for the path.

+========================+=========================================+| Office Server| CLSID Key|+========================+=========================================+| Access.Application| {73A4C9C1-D68D-11D0-98BF-00A0C90DC8D9}|+————————+—————————————–+| Excel.Application| {00024500-0000-0000-C000-000000000046}|+————————+—————————————–+| FrontPage.Application| {04DF1015-7007-11D1-83BC-006097ABE675}|+————————+—————————————–+| Outlook.Application| {0006F03A-0000-0000-C000-000000000046}|+————————+—————————————–+| PowerPoint.Application | {91493441-5A91-11CF-8700-00AA0060263B}|+————————+—————————————–+| Word.Application| {000209FF-0000-0000-C000-000000000046}|+————————+—————————————–+ Does the path match the actual location of the file? Be aware that short path names can give you the impression that a path is correct when it may not be. For example, both Microsoft Office and Microsoft Internet Explorer (if installed in their default locations) will have a short path similar to “C:\PROGRA~1\MICROS~X\” where X is some number. It is not immediately obvious that you are looking at from a short path name.
You can test that the path is indeed correct by copying the value from the registry and pasting it into the Start and then Run dialog box (remove the /Automation switch before running the application). Does the application start when you select OK? If yes, then the server is registered correctly. If not, you should replace the value of the LocalServer32 key with the correct path (use a short path name if possible).Problems have been known to occur when automating Word or Excel if either the Normal.dot template (Word) or the Excel.xlb resource file (Excel) has become corrupt. To test if a corruption has occurred, search the local hard drives to find all instances of Normal.dot or *.xlb. (Please note that if you are running Windows 2000, Windows NT, or Windows 95/98 with profiles enabled, you may find multiple copies of these files, one for each user profile on the system.) Temporarily rename the Normal.dot file(s) or the *.xlb file(s), and re-run your Automation test (Word and Excel will create these files if they cannot find them). Does the code now work? If yes, then the files you renamed should be deleted since they are corrupt. If not, you should rename them back to their original names so any custom settings saved in these files won’t be lost.If you are on a Windows NT, Windows 2000, Windows XP, or Windows Server 2003 system, run the application under the Administrator account. Office servers require read/write access to the registry and disk drive, and may not properly load if your current security settings deny this privilege.
Checking the SystemSystem configuration can also cause problems with the creation of out-of-process COM servers. The following are some things to check on systems where the error occurs: Does the problem happen with any out-of-process server? If you have an application that just uses a particular COM server (for example, Word), you’ll want to test a different out-of-process server to make sure the problem is not with COM layer itself. If no out-of-process COM server can be created on that system, then a reinstallation of the OLE system files (see below) or a reinstallation of the operating system will be required to resolve the issue.Check the version numbers for the OLE system files that manage Automation. These files are typically installed as a set, and should match build numbers. An improperly configured setup utility can mistakenly install the files separately, causing them to become mismatched. To avoid problems with Automation, you should check the files to make sure the files match builds.
You will find the Automation files in the Windows\System or Winnt\System32 directory. The following is the list of files to check:

+—————+————-+—————-+| File Name|Version| Date Modified|+—————+————-+—————-+| Asycfilt.dll|2.40.4275| March 08, 1999 || Oleaut32.dll|2.40.4275| March 08, 1999 || Olepro32.dll|5.0.4275| March 08, 1999 || Stdole2.tlb|2.40.4275| March 08, 1999 |+—————+————-+—————-+ Check the file version by right-clicking on the file in Explorer and selecting Properties from the popup menu. The values most important are the last four digits of the file version (the build number) and the date last modified. You want to make sure these values are the same for all the Automation files.
Please note that the version numbers and dates given above are for example purposes only. Your values may differ. The important thing is that these values match each other, rather than this table.
If the files don’t match build numbers or modified dates, you can download a self-extracting utility that will update your Automation files. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
290887?(http://support.microsoft.com/kb/290887/) VBRun60sp6.exe installs Visual Basic 6.0 SP6 run-time filesWindows NT 4.0 has a known problem with starting Automation servers that live in a folder that contains an embedded space in the name, and/or resembles another folder whose first 8 characters are identical. For example, a server living in C:\Program Files\SomeFolder may fail to start during a call to CreateObject if there is another folder on the system called C:\Program Stuff\SomeFolder. For more information, see the following Knowledge Base article:For additional information about this problem and steps to workaround it, click the article number below to view the article in the Microsoft Knowledge Base:
185126?(http://support.microsoft.com/kb/185126/EN-US/) BUG: COM/OLE Server Fails to Start on Windows NT 4.0
Reinstalling Microsoft OfficeIf none of the preceding steps helps to resolve the problem, consider uninstalling and reinstalling Microsoft Office. Microsoft recommends that you uninstall the existing version first, and then reinstall from the original installation disks.
For a complete list of the items to be removed, please see the following Knowledge Base articles:
219423?(http://support.microsoft.com/kb/219423/EN-US/) OFF2000: How to Completely Remove Microsoft Office 2000
158658?(http://support.microsoft.com/kb/158658/EN-US/) OFF97: How to Completely Remove Microsoft Office 97

INFO: New Tracing Feature in ASP.NET

Symptoms
This article provides information about the new tracing feature in ASP.NET. This article also describes how to configure this tracing feature.
Resolution
The tracing feature allows you to track the execution of an application and view the results. You can enable tracing at the page level or the application level. Enable Tracing at the Page Level When you enable tracing at the page level, the trace output is added to the bottom of the page. The following code sample demonstrates how to enable tracing at the page level:
Visual Basic .NET

<%@Page Language=”vb” Trace=”true”%><script runat=”server”>Public Function TracingTest(strNow as String) as StringTrace.Write(“Now() Value in the function”, now())return “The time is: ” & strNowend Function</script>TracingTest result: <%=TracingTest(Now())%> Visual C# .NET

<%@ Page Language=”c#” Trace=”true”%><script runat=”server”>public string TracingTest(string strNow){Trace.Write(“Now() Value in the function”,DateTime.Now.ToString());return “The Time is: ” + strNow;}</script>Tracing Test Results:<%=TracingTest(DateTime.Now.ToString())%> Visual J# .NET

<%@ Page Language=”VJ#” Trace=”true”%><%@ import namespace = “System.Diagnostics” %><%@ import namespace = “System” %><script runat=”server”>public System.String TracingTest(System.String strNow){Trace.Write(“Now() Value in the function”,DateTime.get_Now().ToString());return “The Time is: ” + strNow;}</script>Tracing Test Results:<%=TracingTest(DateTime.get_Now().ToString())%> When you run this page, both of the results from the function are written to the browser. You also see the information that tracing returns.
To remove the trace information, set the Trace attribute of the @ Page directive to false. You do not need to remove the Trace.Write statement. Notice that this is the TraceContext class, not the Trace class.
To enable tracing at the page level in Microsoft Visual Studio .NET, you can also set the trace property of the document to true in the Properties window. Enable Tracing at the Application Level To enable tracing at the application level, use the Web.config file. The following code sample demonstrates how to configure tracing at the application level in the Web.config file:

<configuration><system.web><trace enabled=”true” requestLimit=”10″ pageOutput=”true”traceMode=”SortByTime” localOnly=”true”/></system.web></configuration> When you enable tracing at the application level, you can use the pageOutput attribute to specify whether the trace output is displayed at the page level. If you set pageOutput to true, the output displays the same results as if you set the Trace attribute of the @ Page directive at the top of the page to true.
NOTE: The trace setting at the page level overrides the trace setting at the application level.

How To Use the Registry API to Save and Retrieve Setting

Symptoms
Although Visual Basic includes the SaveSetting and GetSetting functionsto save and retrieve information from the registry, these functions onlyoperate on a specific section of the registry, the Visual Basic and VBAProgram Settings of the HKEY_CURRENT_USER root key.
This article outlines the use of 32-bit Windows API functions, which can beused to set and retrieve values from anywhere in the registry. The topicsand function references in this article can be generalized to program the16-bit registry.
The 32-bit API functions also include support for security, although anoverview of security is outside the scope of this article.
NOTE: The SaveSetting and GetSetting functions are not part of the VBAfunction library. However, the sample code below still applies to 32-bitapplications that implement VBA.
Resolution
General Registry InformationThe registry is used by applications and Windows to store configurationdata. It is a replacement for the large numbers of INI files thatproliferated on Windows 3.x machines and is also used heavily by OLE.
The registry is organized using a hierarchical series of keys and valuesresembling a tree. Each key, beginning with one of the six predefined rootkeys, can have sub-keys and values associated with it. The keys areorganizational and naming units and appear in the Windows Registry Editorsas file folders. Values are data entries and appear as text entries in theright pane of the Registry Editor window. Keys need not have any associatedvalues, but may have many. Each value has an associated data type. The twomost commonly used registry data types are REG_SZ, a null-terminatedstring; and REG_DWORD, a 32-bit number.
The basic process used to write or read from a location in the registry isthe same. To reference any given key or value, you must have a handle tothe key. Once this handle is obtained, values and sub-keys of the key thatthis handle refers to can be read, set, or listed (enumerated).
Given a location in the registry, to obtain a handle to that key, you mustbegin with one of the six predefined keys (HKEY_CLASSES_ROOT,HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_CURRENT_CONFIG, andHKEY_DYN_DATA) and traverse the registry tree until the desired key isreached. User programs most often read and write from HKEY_CURRENT_USER andHKEY_LOCAL_MACHINE. If the keys being traversed exist already, you can usea series of calls to the RegOpenKey or RegOpenKeyEx functions. If the keysneed to be created, the RegCreateKey and RegCreateKeyEx functions do the job.
With the handle to the desired key, the functions used to list, set, andretrieve information can be called. In all cases, the functions with the Exsuffix will work only on 32-bit platforms. Functions without the suffix maywork on both 16-bit and 32-bit versions of Windows. Keep in mind that notall registry functions lacking the ‘Ex’ suffix are functions provided for16-bit compatibility. The Ex suffix was only added when the capabilities of16-bit functions were expanded. Functions that are totally new and specificto 32-bit platforms do not possess an Ex extension.
The RegSetValue and RegSetValueEx functions allow the settings of a valueto be modified, while RegQueryValue and RegQueryValueEx retrieve thecurrent setting of a value. The limitations of the non-Ex, 16-bit versionsof these APIs are very evident here. When using the 16-bit RegSetValuefunction there is no way to name a value, and because of this, RegSetValuecan’t be used to associate more than one value with each key. In addition,all values written with RegSetValue have a data type of REG_SZ. Theselimitations are inherent with the 16-bit Registry. RegSetValueEx allows thecreation of a multiple number of values with any available data type.
How to Write to a Specific Registry LocationAfter determining what functions you will need to use for your project,copy the relevant declares from the code at the end of this article to abasic module. The two Visual Basic procedures included (SetValueEx andQueryValueEx) are wrappers for the RegSetValueEx and RegQueryValueEx APIfunctions and greatly simplify their use. The notes below make use of theseVisual Basic functions; however, you are free to make calls directly to theAPI if you wish.
Creating/Modifying Keys and Values:
With the declarations and procedures available, you can create and openkeys, and add, modify, and read values. The three following sectionsexplain how to create a key, set or modify a value, and query a value.
Creating a New Key:
Creating a new key is as simple as using the following procedure.CreateNewKey takes the name of the key to create, and the constantrepresenting the predefined key to create the key under. The call toRegCreateKeyEx doesn’t take advantage of the security mechanisms allowed,but could be modified to do so. A discussion of Registry security isoutside the scope of this article.

Private Sub CreateNewKey (sNewKeyName As String, lPredefinedKey As Long)Dim hNewKey As Long’handle to the new keyDim lRetVal As Long’result of the RegCreateKeyEx functionlRetVal = RegCreateKeyEx(lPredefinedKey, sNewKeyName, 0&, _vbNullString, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, _0&, hNewKey, lRetVal)RegCloseKey (hNewKey)End Sub
With this procedure a call of:

CreateNewKey “TestKey”, HKEY_LOCAL_MACHINE
will create a key called TestKey immediately under HKEY_LOCAL_MACHINE.
Calling CreateNewKey like this:

CreateNewKey “TestKey\SubKey1\SubKey2″, HKEY_LOCAL_MACHINE
will create three-nested keys beginning with TestKey immediately underHKEY_CURRENT_USER, SubKey1 subordinate to TestKey, and SubKey3 underSubKey2.
Setting/Modifying a Value:
Creating and setting a value of a specified key can be accomplished withthe following short procedure. SetKeyValue takes the key that the valuewill be associated with, the name of the value, the setting of the value,and the type of the value (the SetValueEx function only supports REG_SZ andREG_DWORD, but this can be modified if necessary). Specifying a new valuefor an existing sValueName will modify the current setting of that value.

Private Sub SetKeyValue (sKeyName As String, sValueName As String, _vValueSetting As Variant, lValueType As Long)Dim lRetVal As Long’result of the SetValueEx functionDim hKey As Long’handle of open key’open the specified keylRetVal = RegOpenKeyEx(HKEY_CURRENT_USER, sKeyName, 0, _KEY_SET_VALUE, hKey)lRetVal = SetValueEx(hKey, sValueName, lValueType, vValueSetting)RegCloseKey (hKey)End Sub
A call of:

SetKeyValue “TestKey\SubKey1″, “StringValue”, “Hello”, REG_SZ
will create a value of type REG_SZ called “StringValue” with the setting of”Hello.” This value will be associated with the key SubKey1 of “TestKey.”
In this case, “TestKey” is a subkey of HKEY_CURRENT_USER, but this can bemodified by changing the call to RegOpenKeyEx. This call will fail if”TestKey\SubKey1″ does not exist. To avoid this problem, use a call toRegCreateKeyEx instead of a call to RegOpenKeyEx. RegCreateKeyEx will opena specified key if it already exists.
Querying a Value:
The next procedure can be used to ascertain the setting of an existingvalue. QueryValue takes the name of the key and the name of a valueassociated with that key and displays a message box with the correspondingvalue. It uses a call to the QueryValueEx wrapper function defined below,that only supports REG_SZ and REG_DWORD types.

Private Sub QueryValue (sKeyName As String, sValueName As String)Dim lRetVal As Long’result of the API functionsDim hKey As Long’handle of opened keyDim vValue As Variant’setting of queried valuelRetVal = RegOpenKeyEx(HKEY_CURRENT_USER, sKeyName, 0, _KEY_QUERY_VALUE, hKey)lRetVal = QueryValueEx(hKey, sValueName, vValue)MsgBox vValueRegCloseKey (hKey)End Sub
With this procedure, a call of:

QueryValue “TestKey\SubKey1″, “StringValue”
will display a message box with the current setting of the “StringValue”value, and assumes that “StringValue” exists in the “TestKey\SubKey1″ key.
If the Value that you query does not exist then QueryValue will return anerror code of 2 – ‘ERROR_BADKEY’.
Additional Notes:
The above examples use the extended 32-bit versions of the registryfunctions exclusively. These functions allow more than one value to beassociated with each key. As discussed above, the 16-bit RegSetValue andRegQueryValue act on a single value associated with the current key (whichis always of the type REG_SZ). These functions appear in the 32-bitRegistry Editor with a name of <NO NAME>. To set, modify, or query thisspecial associated value, one must use the 16-bit registry functions.Reading and writing from the registry in a 16-bit environment is muchsimpler than in a 32-bit environment. The same basic procedure is followed:open a key and get a handle and then call your modification function withthat handle, but no consideration needs to be made for multiple associatedvalues or for different value data types. A 16-bit application can createand modify keys and values with the declarations of the RegCreateKey,RegOpenKey, RegQueryValue, RegSetValue, and RegCloseKey functions.
In some cases, there is no need for any values to be associated with a key.An application may only need to know if a certain key or value exists, andnot care about the nature of the key’s values. In a situation like this,the RegEnumKey, RegEnumKeyEx, and RegEnumValue functions can be used todetermine whether a certain key or value exists. For more information onthese functions refer to the API Text Viewer and/or Windows API reference.
API Function and Constant Declarations

Option ExplicitPublic Const REG_SZ As Long = 1Public Const REG_DWORD As Long = 4Public Const HKEY_CLASSES_ROOT = &H80000000Public Const HKEY_CURRENT_USER = &H80000001Public Const HKEY_LOCAL_MACHINE = &H80000002Public Const HKEY_USERS = &H80000003Public Const ERROR_NONE = 0Public Const ERROR_BADDB = 1Public Const ERROR_BADKEY = 2Public Const ERROR_CANTOPEN = 3Public Const ERROR_CANTREAD = 4Public Const ERROR_CANTWRITE = 5Public Const ERROR_OUTOFMEMORY = 6Public Const ERROR_ARENA_TRASHED = 7Public Const ERROR_ACCESS_DENIED = 8Public Const ERROR_INVALID_PARAMETERS = 87Public Const ERROR_NO_MORE_ITEMS = 259Public Const KEY_QUERY_VALUE = &H1Public Const KEY_SET_VALUE = &H2Public Const KEY_ALL_ACCESS = &H3FPublic Const REG_OPTION_NON_VOLATILE = 0Declare Function RegCloseKey Lib “advapi32.dll” _(ByVal hKey As Long) As LongDeclare Function RegCreateKeyEx Lib “advapi32.dll” Alias _”RegCreateKeyExA” (ByVal hKey As Long, ByVal lpSubKey As String, _ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions _As Long, ByVal samDesired As Long, ByVal lpSecurityAttributes _As Long, phkResult As Long, lpdwDisposition As Long) As LongDeclare Function RegOpenKeyEx Lib “advapi32.dll” Alias _”RegOpenKeyExA” (ByVal hKey As Long, ByVal lpSubKey As String, _ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As _Long) As LongDeclare Function RegQueryValueExString Lib “advapi32.dll” Alias _”RegQueryValueExA” (ByVal hKey As Long, ByVal lpValueName As _String, ByVal lpReserved As Long, lpType As Long, ByVal lpData _As String, lpcbData As Long) As LongDeclare Function RegQueryValueExLong Lib “advapi32.dll” Alias _”RegQueryValueExA” (ByVal hKey As Long, ByVal lpValueName As _String, ByVal lpReserved As Long, lpType As Long, lpData As _Long, lpcbData As Long) As LongDeclare Function RegQueryValueExNULL Lib “advapi32.dll” Alias _”RegQueryValueExA” (ByVal hKey As Long, ByVal lpValueName As _String, ByVal lpReserved As Long, lpType As Long, ByVal lpData _As Long, lpcbData As Long) As LongDeclare Function RegSetValueExString Lib “advapi32.dll” Alias _”RegSetValueExA” (ByVal hKey As Long, ByVal lpValueName As String, _ByVal Reserved As Long, ByVal dwType As Long, ByVal lpValue As _String, ByVal cbData As Long) As LongDeclare Function RegSetValueExLong Lib “advapi32.dll” Alias _”RegSetValueExA” (ByVal hKey As Long, ByVal lpValueName As String, _ByVal Reserved As Long, ByVal dwType As Long, lpValue As Long, _ByVal cbData As Long) As Long
SetValueEx and QueryValueEx Wrapper Functions:

Public Function SetValueEx(ByVal hKey As Long, sValueName As String, _lType As Long, vValue As Variant) As LongDim lValue As LongDim sValue As StringSelect Case lTypeCase REG_SZsValue = vValue & Chr$(0)SetValueEx = RegSetValueExString(hKey, sValueName, 0&, _lType, sValue, Len(sValue))Case REG_DWORDlValue = vValueSetValueEx = RegSetValueExLong(hKey, sValueName, 0&, _lType, lValue, 4)End SelectEnd FunctionFunction QueryValueEx(ByVal lhKey As Long, ByVal szValueName As _String, vValue As Variant) As LongDim cch As LongDim lrc As LongDim lType As LongDim lValue As LongDim sValue As StringOn Error GoTo QueryValueExError’ Determine the size and type of data to be readlrc = RegQueryValueExNULL(lhKey, szValueName, 0&, lType, 0&, cch)If lrc <> ERROR_NONE Then Error 5Select Case lType’ For stringsCase REG_SZ:sValue = String(cch, 0)lrc = RegQueryValueExString(lhKey, szValueName, 0&, lType, _sValue, cch)If lrc = ERROR_NONE ThenvValue = Left$(sValue, cch-1)ElsevValue = EmptyEnd If’ For DWORDSCase REG_DWORD:lrc = RegQueryValueExLong(lhKey, szValueName, 0&, lType, _lValue, cch)If lrc = ERROR_NONE Then vValue = lValueCase Else’all other data types not supportedlrc = -1End SelectQueryValueExExit:QueryValueEx = lrcExit FunctionQueryValueExError:Resume QueryValueExExitEnd Function