Visual Studio '97 Microsoft Visual C++ Development System Version 5.0 Readme

© 1997 Microsoft Corporation

Other product and company names herein may be the trademarks of their respective owners.

This document includes updated information for the documentation provided with the Microsoft® Visual C++® development system, version 5.0. The information in this document and in the Help system is more up-to-date than that in the online documentation. Many of the issues outlined in this document will be corrected in upcoming releases.

Contents

Setup Issues

> Do Not Install Visual C++ 5.0 Over an Installation of Visual C++ 4.x

> Protected-Mode CD-ROM Driver Required Under Windows 95 for Visual C++ Installation

> Use Knowledge Base Articles to Solve Setup and Operating Problems

> Applications Built with OLEAUT32.LIB Require AXDIST.EXE and/or NT SP5a

> DAO Setup Requires OLEAUT32.dll 2.20.4054 or Later

> Viewing "ANSI Character Code Chart" in InfoView Requires an English System

> Accessing Online Help Brings Up MSN Dialog Box

> Special Instructions for Installing Visual C++ 5.0 on Far East Operating Systems

> ODBC Setup.exe is Not in REDIST Directory

Build Issues

> Reducing the Size of Header Files for Faster Builds

> Several Project System and Debugger Methods are Disabled When the BuildFinish Event is Fired

> Building ATL Projects from the Command Line Can Generate NMAKE Error

> Help File Names With European Characters Do Not Copy Correctly On Windows 95

Documentation Issues

> Inactive Links in the Online Documentation

> Avoid Disc Swapping During Full-Text Search of the Documentation

> ODBC 3.0 Programmer's Reference and SDK Guide

> Error in the Scribble MDI Drawing Application Documentation

> The Properties Menu Item is Now Located on the View Menu

> Microsoft Oracle ODBC Driver is Missing from the "ODBC Driver List" Topic

> HCW.EXE 4.01 Does Not Support Office 97

> Typographical Error in Circle Tutorial

> Documentation Errors in ATL Tutorial

> Missing Help Topic for "Ignore Export Library" Check Box

> Changes to ATL Stock Property Macros

> Changes to the MFC Reference Documentation

ActiveX Control Issues

> Visual C++ Support for Authenticode

> Some ActiveX Controls Created with Visual Basic Generate Error in ActiveX Test Container on Resize

> Oracle Joins and MSRDC20.OCX (Remote Data Control V2)

> Current, Localized ActiveX Redistributable Components

Language Issues

> Member Templates Not Supported by the Compiler

> Addendums to the __declspec Documentation

> Behavior of In-Constructor Exception Handling Not Correctly Documented

> Size Mismatch for Type bool in Visual C++ 4.2 Programs Built with Visual C++ 5.0

MFC and Other Libraries

> Coexistence of Visual C++ 4.2 and 5.0

> Visual Basic 5.0 Controls in Visual C++ 5.0

> Incomplete Documentation for CWnd::RepositionBars

> I/O Streams Now Exist in the "std" Namespace

> Example Code in the CArchive::MapObject Member Function is Incorrect

> ATL Registrar Fails to Insert Keys Starting with Curly Brace

> Some ATL Object Stock Properties Must Be Initialized Before Use in Visual Basic 5.0 Containers

> ATL.DLL Replaces REGISTER.DLL

> ATL Font and Picture Properties May Require Changes to the IDL File

> ON_WM_SETTINGCHANGE

> TN024 Doesn't Identify all Custom MFC Resource Types

> MFC DAO Classes will Work with Either DAO 3.0 or DAO 3.5

> Using DAO with a Secure Database

> The Hewlett Packard Standard Template Library

> Incorrect Information in the "_spawn, _wspawn Functions" Topic

> MFC Loads Wrong Resource in Extension .dll

> Call _findclose After Using _findfirst or _findnext

> _wgetcwd and _getcwd

> _wtmpnam

> Incorrect Use of TZ Environment Variable

> Using the _popen Function with a Windows Program

> C Runtime _expand Function Returns NULL Upon Failure

> Format Specification Not Supported in COleDateTime and COleDateTimeSpan Classes

> IsBadHugeReadPtr, IsBadHugeWritePtr, IsBadStringPtr, IsBadWritePtr, and Access Violations

> ATL IPropertyPageImpl::Help is implemented incorrectly.

Wizard and other User-Interface Issues

> Use the ATL Object Wizard to Create ATL Objects

> ATL Proxy Generator May Not Properly Destroy VARIANTARGs

> Two New Template Variables Available to Custom AppWizards

> Problems with ClassWizard Generated Wrapper Classes for Visual Basic 5.0 ActiveX Servers

> Newly Added Classes May Not be Displayed in the ClassView

> ATL Controls in Visual Basic 5.0 Containers

> Development Environment is Unresponsive While Processing a VBScript Macro

> Add Microsoft Transaction Server Libraries to your Proxy/Stub Makefile

> ClassView's Add Method and Add Property Dialogs Sometimes Allow Illegal Return Types for Custom Interfaces

Microsoft Transaction Server Issues

> Read Microsoft Transaction Server (MTS) Readme

> MTS Doesn't Install on Windows 95

> Disable Transaction Time-out While Debugging

> Run Transaction Explorer Before Running Components

> No Proxy/Stubs with Dual Interfaces

> SQL Debugging with Visual C++ 5.0 and Microsoft Transaction Server

> ATL Object Wizard Generates Extra Release for Microsoft Transaction Server Code

Microsoft Visual Data Tools

Sample Program Issues

> New Visual C++ 5.0 Samples

> Updated Samples

> ATL Samples COMMAP, CONNECT, and DRAWSERV Do Not Register Correctly When Path Contains Spaces

> CUSTOMWZ Sample Missing Files

> Get Sendtime and Settime Samples From the Compact Disc

> ATL CIRC Sample Fails in Some Containers

> ATLCON Sample Fails Under MinCRT Configurations

> ATLBUTTON Sample Returns Incorrect Property Values

> ATL POLYGON Sample Does Not Build in Release Mode

> Link Error in Debug Build of COM Sample acdual/mfcctrl

> Typo in tan and tanh Sample

> BINDENRL Sample Fails to Copy STDREG32.MDB

> Access Violation in Visual Basic 5 When Running COMEXCEL Sample

> Running OLE SDK Samples

> Running InOLE2 SDK Samples

OLE DB SDK Issues

> OLE DB SDK

> ADO, OLE DB, and Visual C++

> Remove UUID2.LIB from link line of OLE DB SDK TableCopy Sample

> TableCopy Faults with Oracle Data Connections

SQL and SQL Debugging

> Enabling SQL Debugging

> One or More Breakpoints are Disabled Upon Starting Direct Database Debugging

> SQL Server Service Pack 2 Bug May Cause a Failure in CRecordset::Edit Mode

> SQL Debugging Will Be Disabled Following a Lost Server Connection

> SQL Debugging a Disconnected Data Connection May Produce Unexpected Results

> Remote SQL Debugging with Automation Manager Registered as Interactive User

> Visual C++ Starts Automation Manager but Doesn't Shut It Down

Compiler, Linker, Debugger, and MIDL Compiler

> Windbg Cannot Use Visual C++ 5.0 Debugging Information.

> _declspec(novtable)

> _ATL_MIN_CRT and Link Error "unresolved external symbol _main"

> DCOM95 Available for Distributed Applications

> /WS:AGGRESSIVE (Aggressively Trim Process Memory)

> /FD (Generate File Dependencies)

> _MSC_EXTENSIONS Compiler Macro

> Option Precedence and the CL Environment Variable

> /Zm (Specify Memory Allocation Limit)

> Compiler Now Documents Type Library Dependencies

> Keywords _emul and _emulu Not Documented

> New Linker Error: Linker Tools Error LNK1189

> Benefit of Using the Linker's /OPT:ICF Option

> Debugging Windows API Functions with NT Symbols Loaded

> If Screen Flashes During Build or the Wrong Code Page Is Used When Debugging a Console Application

> Incorrect Documentation for the Clean Menu Command

> MIDL2020: error generating type library: save all changes failed

> Error RC2104 : undefined keyword or key name: MFT_STRING

> Error Command Line Warning MIDL1009:unknown argument ignored

> Additional Information on the C2065 Compiler Error

> Documentation for Error C2712 Incomplete

> Compiler Warning (level 4) C2498

> Compiler Warning (level 4) C4238

> Compiler Warning (level 3) C4800

> Compiler Warning (level 1) C4804

> Compiler Warning (level 1) C4805

> Compiler Warning (level 1) C4806

> Compiler Warning (level 1) C4807

> Compiler Warnings (level 1) C4808

> Compiler Warning (level 1) C4809

Visual SourceSafe Issues

> Converting a Project Directly From Source Control

> Using Visual SourceSafe With Keyword Expansion Disables the Ability to Check In Multiple Files

Enterprise Edition Issues

> Change in Terminology for Data View and SQL Debugging

> Database Projects

> Default or Identity Values Are Not Displayed When You Enter New Records into a Table

> Converting VC 4.2 Projects When the Data Connection is Offline

### Setup Issues

Do Not Install Visual C++ 5.0 Over an Installation of Visual C++ 4.x

Installing Visual C++ 5.0 on top of Visual C++ 4.x will render the 4.x tools unusable. Install Visual C++ 5.0 into a directory separate from your Visual C++ 4.x installation. Visual C++ 5.0 can co-exist with a 4.x installation, as long as both versions reside in different directories.

Protected-Mode CD-ROM Driver Required Under Windows 95 for Visual C++ Installation

To install Visual C++ 5.0 under Windows 95, you must be running a protected-mode CD-ROM driver. You can verify this by checking the Device Manager. If you are currently using a real-mode CD-ROM driver, contact your CD-ROM drive manufacturer for an updated driver for Windows 95 before installing Visual C++ 5.0.

Use Knowledge Base Articles to Solve Setup and Operating Problems

You can use the Knowledge Base articles in the MSDN documentation to resolve known installation and operating problems. Select the Search command from the Help menu and search for error message or related keywords to find a problem description and resolution.

Knowledge Base articles, which are written by Microsoft Technical Support Engineers, are available by connecting to http:// www.microsoft.com/kb/. Choose Visual C++ in the Choose a Microsoft product or technology drop-down list. Enter the article number in the Enter a Search Phrase text box, then click Begin Search.

Applications Built with OLEAUT32.LIB Require AXDIST.EXE and/or NT SP5a

Visual C++ 5.0 ships with the latest OLEAUT32.LIB from the ActiveX SDK which exposes entry points into the OLEAUT32.DLL which are not present in the OLEAUT32.DLL that ships with the original NT and Windows 95 operating systems. If you build an OLE-enabled application or component with Visual C++ 5.0, and link with OLEAUT32.DLL, you will need to install the newer OLEAUT32.DLL via the AXDist.exe applet located in the DevStudio\VC\Redist\AXRedist directory on the Visual C++ 5.0 CD-Rom.

If you are targeting Windows NT 3.51, you will need to ensure that NT Service Pack 5a is installed on the target machine.

DAO Setup Requires OLEAUT32.dll 2.20.4054 or Later

The redistributable DAO Setup program that ships with Visual C++ will not run successfully unless OLEAUT32.dll build 2.20.4045 or later is installed and registered on the target computer. The newer version of OLEAUT32.dll must be copied to the target machine's SYSTEM directory, and registered with REGSVR32.exe. An up-to-date version of OLEAUT32.dll can be found on the first disc of Visual C++, in the DevStudioVC\Redist directory.

Viewing "ANSI Character Code Chart" in InfoView Requires an English System

The character codes displayed in the "ANSI Character Code Chart" topic will only display correctly if viewed on English systems using an "ANSI-compatible" codepage.

Accessing Online Help Brings Up MSN Dialog Box

When accessing online help you may get a dialog box asking about your dial-up connection for your online service provider. This occurs because Internet Explorer, which has an option to automatically connect to the online service, is used to display the online documentation. The best way around this is to choose Cancel when asked to connect. You can disable automatic dialup.

To turn off the automatic dialup:

1. Right click on the IE to get the Context menu. Select the Properties.
2. In the dialog, choose the Connection tab.
3. In the Dialing group, uncheck the "Connect to the Internet as needed". This will turn off the Auto dialup.
4. Click on Apply and OK to close the dialog.

Special Instructions for Installing Visual C++ 5.0 on Far East Operating Systems

The Visual C++ installation does not copy over the localized versions of RICHED32.DLL, GAPI32.DLL, and HLP95EN.DLL on machines running a DBCS enabled Operating System. These 3 files are required by some of the ActiveX Controls installed by Visual C++.

If you install this version of Visual C++ on a Far East Operating System, be sure to copy these 3 files from the directory on the Visual C++ CD indicated below into your System directory:

Chinese (PRC) | DevStudio\VC\Redist\Ocx\chs
Chinese (Taiwan) | DevStudio\VC\Redist\Ocx\cht
Japanese | DevStudio\VC\Redist\Ocx\jpn
Korean | DevStudio\VC\Redist\Ocx\kor

ODBC Setup.exe is Not in REDIST Directory

In ODBC 3.0 several of the ODBC Installer functions have been removed, and others have been redesigned. Therefore this Setup program would not work with ODBC 3.0.

The Installer API has been changed to make it more platform independent. For example, functions in the Installer API (such as SQLInstallODBC) that duplicated the work of the Windows SDK Setup program have been removed. In general, it is now the responsibility of the Setup program to copy files during installation.

For more information about creating setup programs that install ODBC 3.0 components and drivers, please refer to Part 3 in the ODBC 3.0 Programmers Reference. To access the ODBC 3.0 Programmers' Reference, open ODBC.hlp which can be found in DevStudio\SharedIDE\Help.

### Build Issues

Reducing the Size of Header Files for Faster Builds

To speed the build process, Visual C++ 5.0 provides the following new defines. Use them to reduce the size of the Win32 header files.

- VC_EXTRALEAN
- WIN32_LEAN_AND_MEAN

Newly generated Visual C++ AppWizard applications automatically benefit from VC_EXTRALEAN. You can also manually define VC_EXTRALEAN to speed the build process of many legacy MFC applications.

Non-MFC C++ and C applications can define WIN32_EXTRA_LEAN and any applicable NOservice defines, such as NOSOUND (see DevStudio\Vc\include\Windows.h), to reduce their build times.

To add these defines, from the Project menu, choose Settings. The Projects settings dialog box appears. Click the C/C++ tab. In the Category list, select Preprocessor. Add the desired definitions to the Preprocessor Definitions box.

Several Project System and Debugger Methods are Disabled when the BuildFinish Event is Fired

Consider the following VBScript event handler:

    Sub Application_BuildFinish(nNumErrors, nNumWarnings)

    if nNumErrors+nNumWarnings = 0 then
    	ExecuteCommand "ToggleOutputWindow"
    	ExecuteConfiguration
    end if

    End Sub

ExecuteConfiguration fails because the BuildFinish event is fired before several project system and debugger commands have been re-enabled. The methods that invoke these commands, like ExecuteConfiguration, will remain disabled between the time that the event is fired and the time the event handler returns. After the Application_BuildFinish event handler returns, these methods will be re-enabled.

Workaround

1. Create a new macro, for example, MyBuild, with the following code:

    Sub MyBuild

    	Build

    	' Add other method calls here that can't appear in the BuildFinish

    	' event handler, such as "ExecuteConfiguration"

    End Sub

2. Always invoke a build by using this new macro instead of using the default Build menu command or toolbar. Note that you can create a custom menu command or toolbar button for your new MyBuild macro by going to the Tools menu, choosing Customize, and using the Commands tab of the dialog.

The Application_BuildFinish VBScript event handler now becomes:

    Sub Application_BuildFinish(nNumErrors, nNumWarnings)

    if nNumErrors+nNumWarnings = 0 then

    	ExecuteCommand "ToggleOutputWindow"

    end if

    End Sub

In this case Build will fire the BuildFinish event and return control to the MyBuild subroutine at which time the ExecuteConfiguration will be enabled. You can see what other methods are disabled simply by looking at the disabled menu items when a build is in progress.

Building ATL Projects from the Command Line Can Generate NMAKE Error

Building an ATL program from the command line can generate NMAKE error U1073. (This problem does not occur when building ATL samples from within the integrated development environment.)

For example, the following command line:

       NMAKE /f beeper.mak CFG="beeper - Win32 Release"

will generate this error:

       NMAKE : fatal error U1073: don't know how to make '".\beeper.h"'

From the command line, ATL projects require two passes to build. The first pass directs MIDL to create a header file that is required for the second pass.

Workaround

Use the following commands to work around this problem:

       nmake /f beeper.mak CFG="beeper - Win32 Release" beeper.h
       nmake /f beeper.mak CFG="beeper - Win32 Release"

Help File Names with European Characters Do Not Copy Correctly on Windows 95

The Help compiler converts the name of the Help file into upper case characters. On Windows 95, this causes problems when the Visual Studio Build System tries to copy a name that contains European characters (such as umlauted characters) to the output directory for the rest of the project build. This is not a problem on Windows NT.

Workaround

Add a copy step with the name of the Help file, in upper case, to the custom build rule on the .hpj file in the project.

### Documentation Issues

Inactive Links in the Online Documentation

Certain types of links in the online documentation do not work. They look like links, but if you click them, nothing happens.

Such inactive links may be due to a setting in your Internet Explorer 3.0 that prevents ActiveX scripts from running.

To enable the links, do the following:

1. Open Internet Explorer 3.0.
2. From the View menu, select Options.
3. In the Options dialog box, select the Security tab.
4. Under Active content, check the Run ActiveX scripts check box.
5. Click Apply.
6. Click Okay.

Avoid Disc Swapping During Full-Text Search of the Documentation

The MSDN CD contains all of the online documentation for all products in Visual Studio 97. If you install MSDN and leave it in the CD drive, you will not have to swap discs to search online content.

If you chose the CD-ROM installation option when you installed Visual C++, you will need to have the Visual C++ CD in your CD ROM drive most of the time. To avoid looking for on-line content that is not on the Visual C++ CD, use the Define Subsets command from the Help menu to create a restricted search subset of the following Visual C++ documentation:

- Welcome to Visual C++ (vcedit)
- Visual C++ Tutorials (vctutor)
- Visual C++ Programmer's Guide (vccore)
- Microsoft Foundation Class Reference (vcmfc)
- C/C++ Language and C++ Libraries (vclang)
- Visual C++ Samples (vcsample)

Use this subset when doing most full-text searches. Use the "Entire Contents" subset when you need to search all of the online documentation and don't care about disc swapping.

ODBC 3.0 Programmer's Reference and SDK Guide

The ODBC 3.0 documentation was not available for integration into Visual C++ 5.0 Infoviewer at the time of manufacture. (The ODBC documentation that you can find in the InfoViewer is for ODBC 2.5)

However, the following Windows Help files (WinHlp32.exe) are installed during setup in the DevStudio\SharedIDE\Help directory:

- ODBC.HLP -- ODBC 3.0 Programmer's Reference
- SDKGUIDE.HLP -- ODBC 3.0 SDK Guide
- ODBCJET.HLP -- ODBC Microsoft Desktop Database Drivers Help
- ODBCJTNW.HLP -- ODBC Desktop Database Drivers - What's New Help

Use the following procedure to add them to the Tools menu:

1. From the Tools menu, select Customize.
2. Choose the Tools tab.
3. Scroll to the bottom of the Menu contents grid, add a string to represent launching one of the Help files. For example, type "ODBC 3.0 Programmer's Reference".
4. In the Command edit box, type "WinHlp32.exe".
5. In the Arguments edit box, type the location of ODBC.hlp. For example, type "C:\Program Files\DevStudio\SharedIDE\Help\ODBC.hlp".
6. Click Close.
7. Repeat for each Help file you wish to use.

Error in the Scribble MDI Drawing Application Documentation

In the topic "Create the Dialog Box," in the procedure, "To create the Pen Widths dialog box," Step 3 suggests that you double-click the dialog box to bring up the dialog box property page. To bring up the property page, right-click the dialog box, and then click Properties from the menu.

The Properties Menu Item is Now Located on the View Menu

In the topics "Associating the Toolbar Button with a Command ID" and "Adding a Tool Tip" in the Scribble MDI Drawing Application, you are instructed to click Properties from the Edit menu. The Properties item is now located on the View menu.

Microsoft Oracle ODBC Driver is Missing From the "ODBC Driver List" Topic

The list of ODBC drivers, found in the "ODBC Driver List" topic, should include the Microsoft Oracle ODBC driver.

HCW.EXE 4.01 Does Not Support Office 97

The version of Microsoft Help Workshop (HCW.exe) that is installed by Visual C++ 5 does not support .rtf files created using Office '97. If you are an Office '97 user creating .rtf files for use with the Microsoft Help Workshop, you can do one of the following:

- Use Word '97 and save the file in Word 6.0 format. (Make sure "Word6.0/95" is in the Save As Type field in the Word '97 Save As dialog.)
- Install version 4.02 of the Microsoft Help Workshop, located in the \DevStudio\VC\Unsupported Tools\HCW directory. This directory is on the disc that includes "Microsoft Visual C++" on the label. (Disc 1 if you purchased Visual C++; Disc 3 if you purchased Visual Studio.)

Typographical Error in Circle Tutorial

In the topic "Creating the Basic Control," the first class name in the table that describes the class templates created by ControlWizards is incorrect. The correct class name is CCircApp.

Class | Files | Comments
CCircApp | CIRC.H CIRC.CPP | Implements the main DLL source. Typically, there is no need to modify this code.

Documentation Errors in ATL Tutorial

The ATL Tutorial contains the following two errors:

- Step 4 includes instructions for removing the DllMain entry point. Because the ATL COM AppWizard no longer sets DllMain as the entry point, this step is unnecessary.
- In Step 6, the statement,

      #include Polygon.h

  should be replaced by

      #include "Polygon.h"

Missing Help Topic for "Ignore Export Library" Check Box

On the Link tab, General category, when a DLL project (/DLL is one of the link options) is selected in the file tree, there is a new check box, Ignore export library. The context-sensitive Help for this check box is not available. The Help text for the Ignore export library check box is as follows:

When the Ignore export library box is checked, the parent project will not automatically attempt to link to the export library of the subproject. Select this setting when building a resource-only DLL as a subproject of an EXE.

Changes to ATL Stock Property Macros

The macro IMPLEMENT_SMARTPTR_STOCKPROP has been removed from ATL. The macro IMPLEMENT_BOOL_STOCKPROP has been added and should be used for all stock properties that are boolean values, such as the standard AUTOSIZE, BORDERVISIBLE, ENABLED, TABSTOP, and VALID stock properties.

Changes to the MFC Reference Documentation

Three changes to the MFC Reference documentation are included below.

1. Details aboutCOleDateTime
   If you create a COleDateTime object with a date less than 100, the date will be accepted, but subsequent calls to GetYear, GetMonth, GetDay, GetHour, GetMinute, and GetSecond will fail and return -1.
   Previously, you could use two-digit dates, but dates must be 100 or greater in VC++ 4.2.To avoid problems, specify a four-digit date. For example:
   COleDateTime.mytime(1996,1,1,0,0,0);
2. A new override of GetHttpConnection was added:
   CHttpConnection* GetHttpConnection(LPCTSTR pstrServer, DWORD dwFlags, INTERNET_PORT nPort = INTERNET_INVALID_PORT_NUMBER, LPCTSTR pstrUserName = NULL, LPCTSTR pstrPassword = NULL);
3. The following replacement topic for CInternetSession::OpenURL.

CInternetSession::OpenURL

CStdioFile* OpenURL( LPCTSTR pstrURL, DWORD dwContext = 1,

DWORD dwFlags = 0, LPCTSTR pstrHeaders = NULL, DWORD

dwHeadersLength = 0 );

Throw ( CInternetException );

Return Value

Returns a file handle for FTP, GOPHER, HTTP, and FILE-type Internet services only. Returns NULL if parsing was unsuccessful. The pointer that OpenURL returns depends on pszURL's type of service. The table below illustrates the possible pointers OpenURL can return.

URL type Returns

file://CStdioFile*

http://CHttpFile*

gopher://CGopherFile*

ftp://CInternetFile*

Parameters

pstrURL A pointer to the name of the URL to begin reading. Only URLs beginning with file:, ftp:, gopher:, or http: are supported. ASSERTS if pszURL is NULL.

dwContext An application-defined value passed with the returned handle in callback.

dwFlags The flags describing how to handle this connection. The valid flags, which can be combined with the bitwise OR operator (|), are:

- INTERNET_FLAG_TRANSFER_ASCII The file is transferred as a text file.
- INTERNET_FLAG_TRANSFER_BINARY The file is transferred as a binary file.
- INTERNET_FLAG_RELOAD Get the data from the wire even if it is locally cached.
- INTERNET_FLAG_DONT_CACHE Do not cache the data, either locally or in any gateways.
- INTERNET_FLAG_SECURE This flag is applicable to HTTP requests only. It requests secure transactions on the wire with Secure Sockets Layer or PCT.
- INTERNET_OPEN_FLAG_USE_EXISTING_CONNECT If possible, reuse the existing connections to the server for new requests generated by OpenURL instead of creating a new session for each connection request.
- INTERNET_FLAG_PASSIVE Used for an FTP site. Uses passive FTP semantics. Used with CInternetConnection of OpenURL.

pstrHeaders A pointer to a string containing the headers to be sent to the HTTP server.

dwHeadersLength The length, in characters, of the additional headers. If this is -1L and pstrHeaders is non-NULL, then pstrHeaders is assumed to be zero terminated and the length is calculated.

Remarks

Call this member function to send the specified request to the HTTP server and allow the client to specify additional RFC822, MIME, or HTTP headers to send along with the request. OpenURL, which wraps the Win32 function InternetOpenURL, allows only downloading, retrieving, and reading the data from an Internet server. OpenURL allows no file manipulation on a remote location, so it requires no CInternetConnection object. To use connection-specific (that is, protocol-specific) functions, such as writing to a file, you must open a session, then open a particular kind of connection, then use that connection to open a file in the desired mode. See CInternetConnection for more information about connection-specific functions.

### ActiveX Control Issues

Visual C++ Support for Authenticode

To find the tools necessary for packaging your ATL and MFC controls into cabinet (.cab) files and signing the resulting .cab files, look in the CAB&Sign directory. This directory is on the disc that includes "Microsoft Visual C++" on the label. (Disc 1 if you purchased Visual C++; Disc 3 if you purchased Visual Studio.)

For more information on how to use these tools, see http://www.microsoft.com/visualc/reference/cab.htm.

Some ActiveX Controls Created with Visual Basic Generate Error in ActiveX Test Container on Resize

Microsoft Visual Basic 5.0 supports the creation of ActiveX Controls (OCX's). Some controls that are created with Visual Basic set the OLEMISC_NOUIACTIVATE bit. If the control is inserted into the ActiveX Test Container and then is resized, the ActiveX Test Container attempts a DoVerb (OLEIVERB_UIACTIVATE) call that results in the following error:

"Failed to connect. Link may be broken."

This problem is being investigated. This does not impede hosting the control in Visual C++.

Oracle Joins and MSRDC20.OCX (Remote Data Control V2)

If you use the Microsoft ODBC Driver for Oracle with the Microsoft Remote Data Control (MRDC20.OCX) and your SQL statement contains a join (or includes a reference to a view that contains a join), you may encounter the following driver error:
"SC100: [Microsoft][ODBC Driver for Oracle]Driver not capable"

Workaround

Change the CursorDriver, LockType, and ResultsetType properties. The following settings will work:

CursorDriver = 'ODBC Cursor'

LockType = ' Optimistic Concurrency'

ResultsetType = 'Create a Static Cursor'

Current, Localized ActiveX Redistributable Components

The ActiveX redistributable components that ship with Visual C++ 5.0 were current when the product was released to manufacturing. You can always check http://www.microsoft.com/intdev/sdk/ for the most current components.

Note&NBSP;&NBSP; If your Internet application will be used in an Internet Explorer localized environment, your application should use the localized ActiveX components that are available from this site, otherwise the components contained on this CD may overwrite Internet Explorer localized components.

### Language Issues

Member Templates Not Supported by the Compiler

Simple member templates may not generate a compiler error. Use of member templates can result in undefined behavior.

Addendums to the __declspec Documentation

The documentation for the __declspec keyword is missing the following information:

Addendum One

The __declspec keywords should be placed at the beginning of a simple declaration. __declspec keywords placed after * or & and in front of the variable identifier in a declaration will be ignored by the compiler without error message or warnings. See the __declspec topic in Language Quick Reference for more information about using the __declspec attributes.

Addendum Two

The following three declarations are equivalent:

    #define WINAPI __declspec(nothrow) __stdcall

    void WINAPI foo1();

    void __declspec(nothrow) __stdcall foo2();

    void __stdcall foo3() throw();

Using "void __declspec(nothrow) __stdcall foo2();" has the advantage that you can use an API definition, such as the illustrated by the #define statement, to easily specify nothrow on a set of functions. The third declaration, "void __stdcall foo3() throw();" is the syntax defined by the C++ standard.

Behavior of In-Constructor Exception Handling Not Correctly Documented

If you use the operator new without any extra arguments, and compile with the /GX, /EHs, or /EHa option, the compiler will generate code to call operator delete if the constructor throws an exception.

If you use the placement new form of the new operator, the form with arguments in addition to the size of the allocation, the compiler does not support a placement form of the delete operator if the constructor throws an exception.

Example

    class A {

    public:

        A(int) { throw "Fail!"; }

    };

    void foo(void)

    {

        try {

            // heap memory pointed to by pa1 will be deallocated

            // by calling ::operator delete(void*).

            A* pa1 = new A(10);

        } catch (...) {

        }

        try {

            // This will call ::operator new(size_t, char*, int).

            // When A::A(int) does a throw, we should call

            // ::operator delete(void*, char*, int) to deallocate

            // the memory pointed to by pa2, but that's something

            // we don't support yet, so we'll leak memory.

            A* pa2 = new(__FILE__, __LINE__) A(20);

        } catch (...) {

        }

    }

Size Mismatch for Type bool in Visual C++ 4.2 Programs Built with Visual C++ 5.0

In Visual C++4.2, the Standard C++ header files contained a typedef that equated bool with int. In Visual C++ 5.0, bool is implemented as a built-in type with a size of 1 byte. That means that for Visual C++ 4.2, a call of sizeof(bool) yields 4, while in Visual C++ 5.0, the same call yields 1. This can cause memory corruption problems if you have defined structure members of type bool in Visual C++ 4.2 and are mixing object files (OBJ) and/or DLLs built with the 4.2 and 5.0 compilers.

### MFC and Other Libraries

Coexistence of Visual C++ 4.2 and 5.0

The Visual C++ 4.2 and 5.0 library DLLs have the same names. Setup for Visual C++ 5.0 will overwrite your 4.2 system files. Debug information has changed in Visual C++ 5.0 and is not compatible with the Visual C++ 4.2 debugger. Because of this, the Visual C++ 4.2 debugger will not be able to step into the source code of the Microsoft Visual C++ 5.0 MFC or CRT debug libraries. This issue will not affect Visual C++ 4.0 or 4.1 users and does not affect your ability to debug your own source code.

Affected files:

- Standard C Run-Time
- MSVCRTd.DLL
- MSVCRTd.PDB
- MSVCIRTd.DLL
- MSVCIRTd.PDB
- MFC
- MFC42d.DLL
- MFC42d.PDB
- MFC42u.pdb
- MFC42ud.dll
- MFC42ud.pdb
- MFCd42d.dll
- MFCd42d.pdb
- MFCd42ud.dll
- MFCd42ud.pdb
- MFCn42d.dll
- MFCn42d.pdb
- MFCn42ud.dll
- MFCn42ud.pdb
- MFCo42d.dll
- MFCo42d.pdb
- MFCo42ud.dll
- MFCo42ud.pdb

Workarounds

- The best solution is to run Visual C++ 4.2 and 5.0 on separate machines, or operating system installations on the same machine.
- You can use the Visual C++ 5.0 debugger to debug into the MFC or CRT DLLs.
- You can copy the relevant files, listed above, into your Visual C++ 4.2 project's Debug directory.

These files are on your Visual C++ 4.2 compact disc in the \MSDEV\DEBUG directory.

None of these workarounds allows debugging of Release Builds with 4.2 debugger.

NOTE to MFC42b (patch) customers. If you need to recreate the patched MFC DLLs, we have provided the MFC4.2B patch (MFC42B.EXE ) in the \DevStudio\Vc\Debug directory. This directory is on the disc that includes "Microsoft Visual C++" on the label. (Disc 1 if you purchased Visual C++; Disc 3 if you purchased Visual Studio.) You can patch the MFC files by copying them into a temporary directory and running the patch on them. You can ignore the errors about missing files.

The Visual C++ 5.0 files will not otherwise affect the operation of Visual C++ 4.2. Under no circumstances do we recommend replacing the new versions of mfc42.dll, mfc42u.dll, and msvcrt.dll with the versions from 4.2 as you may break other applications dependent on the new versions of these DLL's. The Visual C++ 5.0 Developer Studio will not run with the Visual C++ 4.2 version of mfc42.dll.

Visual Basic 5.0 Controls in Visual C++ 5.0

Below is a list of Visual Basic 5.0 controls provided for your use. Please be aware that many of these controls contain interfaces and behavior that are supported only in Visual Basic 5.0 container applications and are not supported by MFC container applications.

If you have any problems with these controls, please report them at the Web site http://www.microsoft.com/VisualCSupport/report/.

Please note that the controls that shipped with Visual C++ 4.0 and have replacements in Visual C++ 5.0 will no longer be supported by Microsoft's technical support.

The Visual C++ Component Gallery displays all the controls registered on your system. Many of your controls may not have been tested with Visual C++. If you encounter problems with a non-Microsoft control, we encourage you to check with the control vendor for more information.

Filename | Description
COMCT232.OCX | UpDown and Animation controls, version 5.0
COMCTL32.OCX | Common Controls (treeview, imageview, etc.), version 5.0
COMDLG32.OCX | Common Dialogs control (File.Open, Choose.Color, etc.), version 5.0
DBGRID32.OCX | DataBound Grid control
DBLIST32.OCX | DataBound Combo and List controls, version 5.0
MCI32.OCX | Multimedia control, version 5.0
MSCAL.OCX | Calendar control, version 8.0
MSCOMM32.OCX | Communications control, version 5.0
MSMASK32.OCX | Masked edit control, version 5.0
MSFLXGRD.OCX | Read-only DataBound Grid control, version 5.0
MSINET.OCX | FTP and HTTP controls, version 5.0
MSMAPI32.OCX | MAPI Message and Session controls, version 5.0
MSRDC20.OCX | RemoteData control
MSWINSCK.OCX | WinSock control (FTP and HTTP protocols only), version 5.0
PICCLP32.OCX | PictureClip control, version 5.0
RICHTX32.OCX | Rich Edit control, version 5.0
SYSINFO.OCX | System Information control, version 5.0
TABCTL32.OCX | Tabbed Dialog control, version 5.0

Incomplete Documentation for CWnd::RepositionBars

The documentation for CWnd::RepositionBars is missing the parameter bStretch. The prototype should read:

void RepositionBars( UINT nIDFirst, UINT nIDLast, UINT nIDLeftOver, UINT nFlag = reposDefault, LPRECT lpRectParam = NULL, LPCRECT lpRectClient = NULL, BOOL bStretch = TRUE );

bStretch indicates whether the bar should be stretched to the size of the frame.

I/O Streams Now Exist in the "std" Namespace

Per Section 27 of the new ANSI draft, streams are now defined within the std namespace. This means that any program that uses I/O streams must reference the streams within the scope of std.

For example, the following sample will fail to compile, because cout is defined in the std namespace, unless the third line is uncommented:

    // file Test.cpp

    #include <iostream>

    // using namespace std;

    void main()

    {

         cout << "Hello ANSI Committee" << endl;

    }

    // end file Test.cpp

Example Code in the CArchive::MapObject Member Function is Incorrect

In the section SubItem.cpp of the code, nonexistent overloaded CDocument operators (<< and >>) are used in two places. This code section should be replaced with the following code:

    //SubItem.cpp

    void CSubItem::Serialize(CArchive& ar)

    {
    if (ar.IsStoring( ) )
    {

    // will serialize a reference
    // to the "mapped" document pointer

    ar << (CObject *)m_pDoc;
    ar << m_l;
    }

    else

    {

    // Will load a reference to
    // the "mapped" document pointer

    ar >> (CObject *&) m_pDoc;
    ar >> m_l;
    }
    }

ATL Registrar Fails to Insert Keys Starting with Curly Brace

The ATL registrar does not correctly interpret two consecutive key names that both start with a curly brace ({). For example, the second "Implemented Categories" key name fails in the following registry script (rgs):

    HKCR
    {
    	NoRemove CLSID
    	{
    		ForceRemove {333C7BC4-460F-11D0-BC04-0080C7055A83} = s 'Tabular Data Control'
    		{
    			'Implemented Categories'
    			{
    				'{7DD95801-9882-11CF-9FA9-00AA006C42C4}'
    				'{7DD95802-9882-11CF-9FA9-00AA006C42C4}'
    			}
    		}
    	}
    }

Workaround

Break out each key name as shown in this example:

    HKCR
    {
    	NoRemove CLSID
    	{
    		ForceRemove {333C7BC4-460F-11D0-BC04-0080C7055A83} = s 'Tabular Data Control'
    		{
    			'Implemented Categories'
    			{
    				'{7DD95801-9882-11CF-9FA9-00AA006C42C4}'
    			}
    			'Implemented Categories'
    			{
    				'{7DD95802-9882-11CF-9FA9-00AA006C42C4}'
    			}
    		}
    	}
    }

Some ATL Object Stock Properties Must Be Initialized Before Use in Visual Basic 5.0 Containers

Visual Basic 5.0 expects all stock properties that are IUnknown-based (such as MousePointer, Picture, and Font) to contain a valid IUnknown pointer. Otherwise, Visual Basic will never allow the user to change the property. For example, if you have a stock Font property that you never fill in with a valid Font, Visual Basic will display the Font as being NULL, and will never allow the user to select a new Font through the Visual Basic property window.

To avoid this problem, make sure your IUnknown-based stock properties have a valid value other than NULL before inserting your object into a Visual Basic container. There are many ways to do this, for example, get the ambient Font off the container and use that as your stock Font property.

ATL.DLL Replaces REGISTER.DLL

Register.dll, which shipped with Visual C++ Beta 1, has been replaced with Atl.dll. To use the new DLL with your existing ATL projects you will simply need to rebuild them.

ATL Font and Picture Properties May Require Changes to the IDL File

To make a Font or Picture property work in some containers, the interface definition must be declared within the library section of the .idl file. You must cut the interface declarations from the .idl file and paste them into the library section of the same file. In addition, the import line for ocidl.idl needs to be commented out.

For example, the ATL Object Wizard generates the following .idl file for MyCtl with a Font property:

    import "oaidl.idl";
    import "ocidl.idl";

    	[
    		object,
    		uuid(8697BC4C-7A38-11D0-9A38-00A0C90DC94B),
    		dual,
    		helpstring("IMyCtl Interface"),
    		pointer_default(unique)
    	]
    	interface IMyCtl : IDispatch
    	{
    		[propputref, id(DISPID_FONT)]
    		HRESULT Font([in]IFontDisp* pFont);
    		[propput, id(DISPID_FONT)]
    		HRESULT Font([in]IFontDisp* pFont);
    		[propget, id(DISPID_FONT)]
    		HRESULT Font([out, retval]IFontDisp** ppFont);
    	};
    [
    	uuid(8697BC3F-7A38-11D0-9A38-00A0C90DC94B),
    	version(1.0),
    	helpstring("MyControl 1.0 Type Library")
    ]
    library MYCONTROLLib
    {
    	importlib("stdole32.tlb");
    	importlib("stdole2.tlb");

    	[
    		uuid(8697BC4D-7A38-11D0-9A38-00A0C90DC94B),
    		helpstring("MyCtl Class")
    	]
    	coclass MyCtl
    	{
    		[default] interface IMyCtl;
    	};
    };

The corrected version of this .idl file is shown below:

    import "oaidl.idl";
    // import "ocidl.idl";

    [
    	uuid(8697BC3F-7A38-11D0-9A38-00A0C90DC94B),
    	version(1.0),
    	helpstring("MyControl 1.0 Type Library")
    ]
    library MYCONTROLLib
    {
    	importlib("stdole32.tlb");
    	importlib("stdole2.tlb");

    	[
    		object,
    		uuid(8697BC4C-7A38-11D0-9A38-00A0C90DC94B),
    		dual,
    		helpstring("IMyCtl Interface"),
    		pointer_default(unique)
    	]
    	interface IMyCtl : IDispatch
    	{
    		[propputref, id(DISPID_FONT)]
    		HRESULT Font([in]IFontDisp* pFont);
    		[propput, id(DISPID_FONT)]
    		HRESULT Font([in]IFontDisp* pFont);
    		[propget, id(DISPID_FONT)]
    		HRESULT Font([out, retval]IFontDisp** ppFont);
    	};

    	[
    		uuid(8697BC4D-7A38-11D0-9A38-00A0C90DC94B),
    		helpstring("MyCtl Class")
    	]
    	coclass MyCtl
    	{
    		[default] interface IMyCtl;
    	};
    };

ON_WM_SETTINGCHANGE

The windows message map entry ON_WM_SETTINGCHANGE corresponds to the MFC member function with this prototype:

    afx_msg void OnSettingChange( UINT uFlags, LPCTSTR lpszSection );

Parameters

uFlags | When the system sends the message as a result of a SystemParametersInfo call, this parameter is a flag that indicates the system parameter that was changed. For a list of values, see the SystemParametersInfo function in the Win32 Programmers Reference. When an application sends the message, this parameter must be 0.
lpszSection | Points to a string that specifies the name of the section that has changed. (The string does not include the square brackets that enclose the section name.)

Remarks

The framework calls OnSettingChange for all top-level windows when the Win32 SystemParametersInfo function changes a system-wide setting. An application should send the message to all top-level windows when it makes changes to system parameters, and Windows will send the message if the user changes settings via the Control Panel.

The ON_WM_SETTINGCHANGE message is similar to the ON_WM_WININICHANGE message, with the following difference:

- Use ON_WM_SETTINGCHANGE when running Windows NT 4.0 or newer, or under Windows 95.
- Use ON_WININICHANGE when running Windows NT 3.51 or older. This message is now obsolete.

You should have only one of these macros in your message map. To write a program that works for both Windows 95 and Windows NT 4.0, write a handler for ON_WM_SETTINGCHANGE. Under Windows NT 3.51, your handler will be called by uFlags will always be zero.

See Also

SystemParametersInfo and WM_SETTINGCHANGE in the Win32 Programmers Reference, and ON_WININICHANGE and CWnd::OnWinIniChange in the MFC Reference.

TN024 Doesn't Identify all Custom MFC Resource Types

MFC Technote TN024, titled "MFC-Defined Messages and Resources", states that:

"There is currently only one MFC private resource format defined, RT_DLGINIT."

This statement should read:

"Currently, MFC defines two private resource formats: RT_DLGINIT and RT_TOOLBAR."

The default toolbar supplied by AppWizard is based on an RT_TOOLBAR custom resource, which was introduced in MFC 4.0.

You can edit this resource with the toolbar editor.

MFC DAO Classes will Work with Either DAO 3.0 or DAO 3.5

However the MFC DAO classes have not been designed to take advantage of any new DAO 3.5 features, including ODBCDirect.

Using DAO with a Secure Database

If you are writing a program that uses Data Access Objects (DAO) to access a secure database, you will receive an error if you use CDaoRecordset because MFC does not prompt the user for a user name and password. To find out how to call DAO directly to implement DAO security features, such as changing user passwords, see Technical Note 054 in the Microsoft Foundation Class Reference. The title is "TN054: Calling DAO Directly While Using MFC DAO Classes."

The Hewlett Packard Standard Template Library

Visual C++ 5.0 ships a complete, fully supported C++ Standard Run-time Library, that includes the Microsoft implementation of the Standard Template Library.

Setup installs the new C++ Standard Run-time Library with the other run-time libraries.

Note

The Hewlett Packard Standard Template Library that shipped with Visual C++ 4.0 does not ship with Visual C++ 5.0. Microsoft does not provide technical support for the Hewlett Packard version of the Standard Template Library.

Incorrect Information in the " _spawn, _wspawn Functions" Topic

In the topic titled "_spawn, _wspawn Functions", a table in the Remarks section has wrong information. The table is labeled "Generic-Text Routine Mappings." The far right column of the table, which has the heading "_UNICODE Defined," should list all the _wspawn functions instead of the spawn functions. When the _UNICODE flag is defined, the wide-character (_w) versions of the functions are used.

MFC Loads Wrong Resource in Extension .dll

The wrong resource is loaded when CBitmap::LoadBitmap, CMenu::LoadMenu, CString::LoadString or any other MFC resource-loading function is called in an MFC extension .dll (AFXDLL). In some cases, a resource in the application is loaded instead of the appropriate resource in the extension .dll.

When a resource in the application or another extension .dll gets loaded instead of a resource in the current extension .dll, the cause is usually improper resource management. An MFC application and all of its extension DLLs are one global chain of resources. If there are multiple resources with the same ID value in any of the modules in the chain, MFC uses the first resource it finds with the desired ID value. The first resource is often found in the application, which is searched before any of the extension DLLs.

Change the ID values of any conflicting resources so they are unique in both the application and any extension .dll that the application uses. These values are stored in the Resource.h file for each project and can be modified in the Resource Editor or in Developer Studio with the Resource Symbols command.

To ensure that modules do not use conflicting symbol values, reserve different ranges of ID values for each module in the 1 through 0x6FFFF range. Set the _APS_NEXT_RESOURCE_VALUE definition in the Resource.h file for each module to the low end of that module's range before creating any resources. The Resource Editor uses this symbol to determine the ID value of the next resource created.

This technique is documented in MFC Technical Note 35 and in the DLLHUSK sample included with Visual C++.

In .exe or .dll files that link to MFC dynamically, MFC resource-loading functions call AfxFindResourceHandle to obtain the handle of the module where a resource is located. AfxFindResourceHandle searches for resources by type and symbol value in:

- The module returned by AfxGetResourceHandle. This is usually the application.
- The extension DLLs through the chain of CDynLinkLibrary objects.
- Any language-specific resource DLLs.
- Any attached MFC system DLLs (MFCxx.dll, for example).

Note

Some 16-bit MFC resource loading functions do not call AfxFindResourceHandle, but instead use the value returned from AfxCurrentResourceHandle.

Each extension .dll creates, initializes, and then passes a CDynLinkLibrary object to AfxInitExtensionModule that places the .dll in the resource chain. AfxTermExtensionModule removes the .dll from the chain when the .dll is detached from the application.

A benefit of this design is that MFC automatically locates a resource for an application or extension .dll, even if that resource is located in a distant extension .dll or the application itself. All resources in the process are chained, so ID values are passed between DLLs and the application and the proper resources are loaded. A disadvantage is that there are no duplicate ID values between any of the extension DLLs or the application that uses them.

To set the default location where AfxFindResourceHandle first checks for a resource, use AfxSetResourceHandle. Because AfxFindResourceHandle first checks the handle set by AfxSetResourceHandle, it can be used to circumvent the chain and load a resource from one particular .dll or application. The resource handle is restored to its original value immediately after loading the resources. The current default resource handle is found with AfxGetResourceHandle.

The DLLHUSK sample included with Visual C++ also illustrates this technique. In Testdll2.cpp, CListOutputFrame::Create sets the resource handle to the module handle stored in the AFX_EXTENSION_MODULE structure extension .dll. This structure is initialized with the module handle when it is passed to the CDynLinkLibrary constructor in InitTestDLL2.

For information on:

- Extension DLLs, see the MFC Technical Note 33 and the DLLHUSK sample.
- Resource management in projects, see Technical Note 35.

Call _findclose After Using _findfirst or _findnext

You must call _findclose after you are finished using either the _findfirst or _findnext function. This will free up resources used by these functions in your application.

_wgetcwd and _getcwd

The documentation for _getcwd and _wgetcwd should describe the second parameter (maxlen) as follows:

maxlen

Maximum length of path in characters- char for _getcwd and wchar_t for _wgetcwd

_wtmpnam

The documentation for _wtmpnam should include the following:

If string is not NULL, it is assumed to point to an array of at least L_tmpnam characters--or 2*L_tmpnam bytes. The value of L_tmpnam is defined in STDIO.H.

Incorrect Use of TZ Environment Variable

The online documentation for the _tzset function incorrectly defines the time bias for the TZ environment variable parameter (tzn) as being the "offset from UTC." It should define it as being the "offset from local time to UTC." The example for German time zone should be:

    set TZ=GST-1GDT

Using the _popen Function with a Windows Program

The _popen function, from the C Runtime Library, returns an invalid file handle if used in a Windows program which causes the program to hang indefinitely. It works properly in a Console application.

To create a Windows application that redirects input and output, read the section "Creating a Child Process that Redirects Input and Output" in the Win32 SDK.

C Runtime _expand Function Returns NULL Upon Failure

The _expand function returns NULL when an error is detected during operation. This may happen when there is sufficient memory. The current documentation implies that failures occur only when there is insufficient memory to expand the memory block. This is incorrect. For example, when _expand is used to shrink a memory block, it might detect a corruption in the small block heap or an invalid block pointer, and returns NULL.

Format Specification Not Supported in COleDateTime and COleDateTimeSpan Classes

The description of the member function Format in both the COleDateTime and the COleDateTimeSpan erroneously states that you can use the %D format specification to display the number of days. Neither COleDateTime::Format nor COleDateTimeSpan::Format support that format specification.

IsBadHugeReadPtr, IsBadHugeWritePtr, IsBadStringPtr, IsBadWritePtr, and Access Violations

A handled exception will occur inside of these functions if the specified memory region is not accessible to the process when these functions attempt to access it. If the code is being executed under a debugger, and the debugger is configured to get first chance at handling exceptions, the debugger will trap the access violation and stop program execution. At this point you can simply continue execution in the debugger and these functions will return the appropriate value. This behavior can help you find potential access violations in your code.

ATL IPropertyPageImpl::Help is implemented incorrectly.

In most cases, if you are using property pages, you should override IPropertyPage::Help and return E_NOTIMPL. This will cause the container to use information returned from GetPageInfo. You can also provide your own alternative implementation of this function if necessary.

### Wizard and Other User-Interface Issues

Use the ATL Object Wizard to Create ATL Objects

Last-minute testing revealed that the ATL ClassWizard can reset properties while editing interfaces and that the ATL ClassWizard allows users to create different interfaces with the same name. This is a known problem and Microsoft is working on it.

Workaround

Once you have used the ATL Com AppWizard, use the ATL Object Wizard to create new ATL objects.

To Access the ATL Object Wizard:

1. Right click your project's classes in ClassView to display the shortcut menu.
2. Click the New ATL Object command.
3. In the left pane of the ATL Object Wizard dialog box, click Objects.
4. Click the Simple Object icon.
5. Click Next.
6. Use the resulting ATL Object Wizard Properties dialog box to define your ATL object.

ATL Proxy Generator May Not Properly Destroy VARIANTARGs

If you have used the multicast component of the ATL Proxy Generator to generate ConnectionPoint broadcast code, (code that calls all active connections on a connection point), then one or more of the generated functions employs zero or more VARIANTARGs that are local to each function. (VARIANTARG is typed as VARIANT using typedef in oaidl.h.) Correct use of VARIANT includes a VariantInit call on the VARIANT before its use and VariantClear afterward. (VariantInit sets a VARIANTARG to a known empty state, VariantClear sets it back to a known state and frees all memory used by the VARIANTARG.) The multicast component calls VariantInit for each VARIANTARG but does not call VariantClear. In some cases, this may result in memory leaks.

Workaround

Manually add call(s) to VariantClear to the code that is generated by the multicast component. An alternative is to change all uses of VARIANTARG to CComVariant and remove the calls to VariantInit because CComVariant calls VariantInit in the constructor and VariantClear in the destructor.

Two New Template Variables Available to Custom AppWizards

root_oem | Same as 'root' except translated to the OEM character set. Affects only upper ASCII characters in the project name (such as an umlauted character).
HM_FILE_OEM | Same as 'HM_FILE' except translated to the OEM character set. Affects only upper ASCII characters in the project name (such as an umlauted character).

The Visual C++ tools work with the ANSI character set. Batch files, such as makehelp.bat, work with the OEM character set--a legacy from the days of DOS 1.0 that still exists. Most printable characters in these two sets are the same. However, there are some differences in some of the upper ASCII values used for European characters such as those that use an umlaut.

Problems with ClassWizard-Generated Wrapper Classes for Visual Basic 5 ActiveX Servers

With Visual Basic 5.0 you can create ActiveX Automation servers with methods that can take Optional and Default parameters of any Visual Basic intrinsic type. If you use MFC and want to access an object of a Visual Basic ActiveX Automation server, you would, typically, use ClassWizard to read the type information of the Visual Basic object and generate a class that wraps the functionality of the Visual Basic Automation object. C++ does not have optional or default parameters and so the wrapper class that ClassWizard generates will not mark parameters as Optional or Default.

For example, if you have a Visual Basic Server with the following function:

    Function function2(Optional parm1 As Integer = 5)

    MsgBox parm1

    End Function

ClassWizard will generate the following C++ wrapper function:

    VARIANT _MyVBObj::function2(short* parm1)

    {

     VARIANT result;

     static BYTE parms[] = VTS_PI2;

     InvokeHelper(0x60030001, DISPATCH_METHOD, VT_VARIANT,

      (void*)&result, parms, parm1);

     return result;

    }

If you call the ClassWizard generated function from your MFC program, you will have to pass the argument even though Visual Basic marked it as Optional.

Workaround

Override the function that ClassWizard generates with versions of the function that take only the parameters you wish to pass. For example, in the preceding case, if you didn't want to pass the optional parameter, override the ClassWizard generated function as follows:

    VARIANT _MyVBObj::function2()

    {

     VARIANT result;

     InvokeHelper(0x60030001, DISPATCH_METHOD, VT_VARIANT,

      (void*)&result, NULL);

     return result;

    }

In the preceding case, the default parameter for the Visual Basic server's function2 would be used.

Newly Added Classes May Not be Displayed in the ClassView

Dependency scanning in Visual C++ 5.0 has changed from earlier versions of Visual C++. Only files that are in the project will be scanned by ClassView. The External Dependency folder is automatically populated by the IDE and is not considered part of your project. If you want to see classes from header files that are in the External Dependencies folder, insert that file into your project. One easy way to insert a file from the External Dependencies folder is by dragging and dropping it into the project.

ATL Controls in Visual Basic 5.0 Containers

If you're using the IQuickActivate interface in Visual Basic 5.0, you must also support IPropertyNotifySink.

To use a control generated by the ATL Object Wizard in a Visual Basic 5.0 container, you must either add support for IPropertyNotifySink or remove dependence on the IQuickActivate interface. To remove IQuickActivate support, comment out the lines containing IQuickActivateImpl in the control's class inheritance list and in the COM interface map.

For example, if you generate a Full Control called MyCtl with the ATL Object Wizard, then go to MyCtl.h and comment out the line containing IQuickActivateImpl in the CMyCtl class inheritance list:

    class ATL_NO_VTABLE CMyCtl :
    ...
    // public IQuickActivateImpl<CMyCtl>

Also, comment out the line containing IQuickActivateImpl in the COM interface map in MyCtl.h:

    BEGIN_COM_MAP(CMyCtl)
    ...
    // COM_INTERFACE_ENTRY_IMPL(IQuickActivate)

Development Environment is Unresponsive While Processing a VBScript Macro

The Visual C++ user interface does not respond to mouse clicks or keystrokes until a macro finishes. Processing a lengthy macro gives the appearance that the user interface has hung. This design prevents indiscriminate interference between macros.

Add Microsoft Transaction Server Libraries to Your Proxy/Stub Makefile

If you are using a separate Proxy/Stub DLL created with the ATL COM Wizard, add the library mtxih.lib as the first library on the link line.

ClassView's Add Method and Add Property Dialogs Sometimes Allow Illegal Return Types for Custom Interfaces

The return type dropdown for Add Method and Add Property should be active only for dispinterfaces and for custom interfaces with the attribute 'local'. The return type is fixed at HRESULT for all other interface definitions--such as dual. Unfortunately, it is active for all non-dual interfaces. The midl compiler will fail with error 2269 when you build your project if you change the return type to something other than HRESULT or SCODE for a property or method in a custom interface that doesn't have the 'local' attribute.

### Microsoft Transaction Server Issues

Feature Only in Enterprise Edition The Microsoft Transaction Server is supported only in Visual C++ Enterprise Editions.

Read Microsoft Transaction Server (MTS) Readme

After installing Microsoft Transaction Server, please consult the Microsoft Transaction Server readme file, located in the docs subdirectory of the Microsoft Transaction Server installation. The file contains information required to install, configure and run program components. The readme also contains descriptions of several useful samples and includes a list of known problems.

MTS Doesn't Install on Windows 95

The Beta version of Microsoft Transaction Server does not run on Windows 95. If you attempt to install it, you will get a message box stating that 'the setup did not complete.' No files or registry keys are affected.

Disable Transaction Time-Out While Debugging

Microsoft Transaction Server uses a time-out mechanism to keep components from deadlocking the system. If the transaction time-out is enabled while you are debugging the component, the transaction context may be destroyed, causing a protection fault. To avoid this, you can disable this time-out from the Microsoft Transaction Server Explorer. Select the My Computer icon and select its properties. Under the Options tab on the Properties dialog box, you will see a transaction time out section. To disable the timeout, set the timeout to 0.

Run Transaction Explorer Before Running Components

Microsoft Transaction Server components are inproc COM servers. Most inproc COM servers require that you run a utility called REGSVR32.exe. The utility places important information about the server into the systems registry. The default build step for MFC and ATL COM servers is to run REGSVR32.exe before completing the build.

Microsoft Transaction Server components are different as they need special registry keys in order to execute. This means that you should run the Microsoft Transaction Server Explorer and install or import the component before executing it. Running REGSVR32.exe after installing or importing the component will change some of the registry keys and will prevent your component from running properly. There are two ways to get around this:

1. If you created your component with MFC, ATL 1.0, or ATL 1.1 and contains the REGSVR32.exe custom build step, you should refresh the component within the Microsoft Transaction Server Explorer after every build. You can tell if REGSVR32.exe is being run as you will see the message 'Registering OLE Server...' in the IDE output window. The registration process is defined in a custom build rule. If you go into the build settings for the component and look at its custom build rules you will see the registration step. You can choose to remove the registration custom build rule for the component.
2. If you created the component with the Visual C++ 5.0 ATL Object Wizard and selected the 'Microsoft Transaction Server object', you only have to install the component with the Microsoft Transaction Server Explorer before executing. The REGSVR32.exe custom build rule has been removed with this option. You should still refresh the component in the Microsoft Transaction Server Explorer whenever you change any COM interfaces you support.

No Proxy/Stubs with Dual Interfaces

The Microsoft Transaction Server Beta software is not capable of inheriting interfaces. The usual example of this is dual interfaces. Dual interfaces inherit from the IDispatch interface. If you create a Microsoft Transaction Server component that uses dual interfaces, you must use type libraries to contain the interface information. If you build a proxy/stub marshaling .dll for your dual interface component, you will get errors from Microsoft Transaction Server. See the Microsoft Transaction Server Readme for more information.

SQL Debugging with Visual C++ 5.0 and Microsoft Transaction Server

You can perform SQL debugging through Microsoft Transaction Server Components. In this case, the component usually calls a stored procedure via ODBC or any other data-access methodology. The component needs to be running locally on the debugging machine as an inproc server. If the component is running remotely on a different machine or as a local server, you will be unable to engage the SQL debugging components. You will also not be able to perform SQL debugging if the transaction started on a different machine as part of the DTC functionality from SQL Server/Microsoft Transaction Server.

To do SQL debugging, follow these steps:

1. Load the client .EXE as the active project workspace in Visual C++ 5.0. This is the client application that you've created.
2. Use the Project/Build Settings dialog to add your inproc server DLL as an additional DLL.
3. Set a breakpoint in each stored procedure that you wish to debug.
4. Start debugging.

You should hit the breakpoints in your stored procedures and should be able to debug them normally. If you have problems, ensure that you can debug the stored procedure directly (i.e. select debug stored procedure instead of running it through the component). Also, make sure that Microsoft Transaction Server is functioning properly. See the Microsoft Transaction Server README for further installation steps.

ATL Object Wizard Generates Extra Release for Microsoft Transaction Server Code

If you select the icon of the MS Transaction Server Component from the right pane of the ATL Object Wizard, and choose to support IObjectControl and pooling from the resulting ATL Object Wizard Properties dialog, the wizard will generate code that performs an extra interface release. This extra release is detected and ignored by Microsoft Transaction Server 1.0 and will not cause your object to fault. Microsoft Transaction Server will log the following message in your event log indicating that it has detected the extra Release:

    An object released more references to its object context than it had acquired. The extra release is ignored.

You can change the generated code to avoid this problem all together. In the Deactivate method within the generated object, look for code similiar to the following:

    void CYourClass::Deactivate()
    {
    	m_spObjectContext->Release();
    }

Replace it with the correct code below, which will release the IObjectContext interface.

    void CYourClass::Deactivate()
    {
    	m_spObjectContext.Release();
    }

### Microsoft Visual Data Tools

Feature Only in Enterprise Edition The Microsoft Visual Data Tools are supported only in Visual C++ Enterprise Editions.

See the Visual DataTools readme.

### Sample Program Issues

The samples on the first Visual C++ CD are accessible from any directory browser (Windows Explorer or File Manager, for example). Sample code remains available for viewing and download from sample abstracts in the documentation.

New Visual C++ 5.0 Samples

Try out the samples located in the \DEVSTUDIO\VC\SAMPLES directory of the first Visual C++ CD. These include examples of using the new compiler support for COM and samples for ATL. They also include a new Custom AppWizard sample.

Updated Samples

The most recent versions of the following samples are in the DevStudio\Vc\Samples directory on the disc that includes "Microsoft Visual C++" on the label. (Disc 1 if you purchased Visual C++; Disc 3 if you purchased Visual Studio.) Do not use the versions that you can find in the InfoViewer's Samples abstracts. Instead, copy the files from the Microsoft Visual C++ disc to your hard drive.

MFC Samples

- OLDBARS
- SUPERPAD
- OLEVIEW
- WORDPAD
- EXTBIND
- MDIBIND
- BINDENRL
- REGSVR
- SMILEY
- DAOCTL
- ODBCINFO

ATL Samples

- CIRC
- POLYGON

Enterprise Samples

- SENDTIME
- SETTIME

Com Samples

- ALLINONE
- INPROC
- LABRADOR

SDK Samples

- AXSCRIPT
- URLPAD

ATL Samples COMMAP, CONNECT, and DRAWSERV Do Not Register Correctly When Path Contains Spaces

These ATL samples do not register correctly when their path contains spaces.

Workaround

Edit their corresponding .RGS files and add single quotes around all occurrences of %MODULE%. For example, you would change a line containing the following:

InprocServer32 = s %MODULE%

to the following:

InprocServer32 = s '%MODULE%'

Note DRAWSERV is a sample program within the DCOM ATL sample.

CUSTOMWZ Sample Missing Files

The CUSTOMWZ sample in the DevStudio\Vc\Samples\appwiz\ directory is missing some essential files.

To obtain the entire sample, with all of its files, install it from the "CUSTOMWZ: A Custom AppWizard" topic in the online documentation. To find this topic, choose the Search command from the Help menu, enter the comma-delimited string, "CUSTOMWZ: A Custom AppWizard", on the Query tab, and then click the Query button.

Get Sendtime and Settime Samples From the Compact Disc

The files for the Sendtime and Settime samples downloaded from the Enterprise sample abstracts in the online documentation will not compile.

Workaround

Manually copy the correct files for these samples from the DevStudio\VC\Samples\Ent\time directory. This directory is on the disc that includes "Microsoft Visual C++" on the label. (Disc 1 if you purchased Visual C++; Disc 3 if you purchased Visual Studio.)

ATL CIRC Sample Fails in Some Containers

For correct functionality in certain containers, objects passing properties must support the propputref semantics. The CIRC sample as installed from the online abstract supports propput instead of propputref. Therefore, you should use the CIRC sample from the DevStudio\Vc\Samples\Atl\circ directory. To see the correct propputref syntax, look in the Circ.idl file. This directory is on the disc that includes "Microsoft Visual C++" on the label. (Disc 1 if you purchased Visual C++; Disc 3 if you purchased Visual Studio.)

ATLCON Sample Fails Under MinCRT Configurations

To successfully run the ATL sample, ATLCON, under a MinCRT configuration, you must remove the WinMain entry point as follows:

1. Click Settings on the Projects menu.
2. In the Settings For: drop-down list, choose one of the MinCRT configurations.
3. On the Link tab, choose the Output category.
4. Remove the text in the Entry-point symbol edit box.

ATLBUTTON Sample Returns Incorrect Property Values

The ATLBUTTON sample returns incorrect values for the properties ImageHover and ImagePush. To correct the sample change the file AtlButton.h so that the function get_ImageHover uses m_bstrFilename[1].Copy() and change get_ImagePush so that it uses m_bstrFilename[2].Copy().

ATL POLYGON Sample Does Not Build in Release Mode

If you copy the ATL POLYGON sample from the online documentation, it will not build in Release mode as it incorrectly defines the _ATL_MIN_CRT macro. The sample on the disc does not have this problem. (Disc 1 if you purchased Visual C++; Disc 3 if you purchased Visual Studio.)

Workaround

1. Select the Settings command from the Project menu
2. Choose the C/C++ tab. In the General category, remove _ATL_MIN_CRT from the Preprocessor definitions edit box.
3. Choose the Link tab. In the Output Category, remove DllMain from the Entry-point symbol edit box.

Link Error in Debug Build of COM Sample acdual/mfcctrl

This sample will fail under debug builds looking for comsuppd.lib. To fix the problem, go into the the Project Settings dialog box and remove _COM_DEBUG from the Preprocessor definitions box in the C/C++ Preprocessor section.

Typo in tan and tanh Sample

In the documentation of tan and tanh, there is a typo in the sample. The current sample shows:

    printf( "tan( %f ) = %f\n", x, y );

    printf( "tanh( %f ) = %f\n", y, x );

It should be:

    printf( "tan( %f ) = %f\n", pi/4, x );

    printf( "tanh( %f ) = %f\n", x, y );

The correct output is:

    tan( 0.785398 ) =  1.000000

    tanh( 1.000000 ) = 0.761594

See both the \DEVSTUDIO\VC\SAMPLES and the \OLEDB\SAMPLES directories on the first Visual C++ CD.

BINDENRL Sample Fails to Copy STDREG32.MDB

To build the BINDENRL sample, you'll need to manually copy the database file stdreg32.mdb into the same local directory that you copy the samples source files. You will find stdreg32.mdb in the DEVSTUDIO\VC\Samples\mcl\mfc\database\daoenrol directory. This directory is on the disc that includes "Microsoft Visual C++" on the label. (Disc 1 if you purchased Visual C++; Disc 3 if you purchased Visual Studio.)

Access Violation in Visual Basic 5.0 When Running COMEXCEL Sample

If you get an access violation while running the COMEXCEL sample in Visual Basic 5.0 under Windows NT V4.0, please install the Windows NT Service Pack 2.

Running OLE SDK Samples

Before you run an OLE SDK sample, you should first copy the following subdirectories from the first VC++ product CD

       DevStudio\VC\Samples\SDK\ole\include
       DevStudio\VC\Samples\SDK\ole\lib

to the following subdirectories on the disk (in this case c:) that will hold the OLE samples

       c:\samples\ole\include
       c:\samples\ole\lib

You can now install the sample files in any directory on the disk (in this case c:) and compilation will find the include and lib directories. If you have an MSTOOLS environment variable defined, you should put the include and lib directories in the following location on your hard disk: MSTOOLS path\samples.

Running InOLE2 SDK Samples

Before you run an InOLE2 SDK sample, you should first copy the following subdirectories from the first VC++ product CD

       DevStudio\VC\Samples\SDK\ole\inole2\inc
       DevStudio\VC\Samples\SDK\ole\inole2\lib

to the following subdirectories on the disk (in this case c:) that will hold the OLE samples

       c:\samples\ole\inole2\inc
       c:\samples\ole\inole2\lib

You can now install the sample files in any directory on the disk (in this case c:) and compilation will find the inc and lib directories. If you have an MSTOOLS environment variable defined, you should put the inc and lib directories in the following location on your hard disk: MSTOOLS path\samples.

### OLE DB SDK Issues

OLE DB SDK

OLE DB is a set of OLE interfaces that provides applications with uniform access to data stored in diverse information sources. These interfaces support the amount of DBMS functionality appropriate to the Data Connection, enabling it to share its data. To learn more about OLE DB, please refer to the SDKGUIDE.hlp, OLEDB1.hlp, and RELNOTES.DOC files located in the \OLEDB\DOC directory on the disc.

To install the OLE DB SDK, run the SETUP.exe program located in the OLEDB folder in the root of the Visual C++ compact disc.

ADO, OLE DB, and Visual C++

ADO is an object model on top of the OLE DB interfaces. It reduces the number of interfaces required to implement an application. ADO also provides a type library which OLE DB does not. If you wish to use OLE DB with the new compiler COM support, you must write to ADO.

Visual C++ 5.0 ships two versions of ADO. The beta version in the OLE DB SDK and the shipping version in redist\ado. Use the shipping version to build and test your application before releasing it. You must also distribute the shipping version of ADO with your application.

Remove UUID2.LIB from link line of OLE DB SDK TableCopy Sample

The TableCopy sample in the OLE DB SDK 1.1 will not compile correctly with Visual C++ 5.0. You will receive a link error stating that UUID2.LIB is not found. This is because UUID.LIB, UUID2.LIB, and UUID3.LIB have been combined in Visual C++ 5.0 in the UUID.LIB file. To fix the build problem, go to Project Settings for the sample, select the Link tab, select All configurations, and remove the UUID2.LIB entry from the Obect/Library Modules line. You should then be able to successfully compile and link this sample.

TableCopy Faults with Oracle Data Connections

The TableCopy sample will not function correctly with an Oracle Data Connection. Select a different Data Connection type to use this sample.

### SQL and SQL Debugging

Feature Only in Enterprise Edition SQL and SQL debugging are supported only in Visual C++ Enterprise Editions.

Enabling SQL Debugging

To enable SQL Debugging, you need to install the Visual C++ Enterprise Edition Server Components on your SQL Server machine. Before you run the setup program for the VC Server Components, you must first install the latest Service Pack for Windows NT, and the latest Service Pack for Microsoft SQL Server. Once these service packs are installed, you will be able to successfully install the Visual C++ Server Components. The setup program can be run directly from the VCServer directory, or from the master setup program in the root directory of Disc 2 (Disc 4 for Visual Studio).

One or More Breakpoints are Disabled Upon Starting Direct Database Debugging

If your workspace includes both a C++ and a database project it is possible to encounter a message that warns of one or more break points being disabled when you begin debugging the database. This happens when you have C++ breakpoint set in your C++ project and you begin debugging the database project before the C++ project. In some cases, the debugger will not be able to find the C++ symbols. The workaround is to first begin debugging the C++ project, which allows the debugger to load the C++ symbols, before you debug the database project.

SQL Server Service Pack 2 Bug May Cause a Failure in CRecordset::Edit Mode

The SQL Server Service Pack 2 (06.50.0240) that ships with the Visual C++ Enterprise Edition has a bug that may cause a failure in CRecordset::Edit mode during the call to CRecordset::Update.

The ODBC driver that ships with this version of SQL Server now gives you the option to turn ON or OFF the following items:

- Use ANSI Quoted Identifiers
- Use ANSI Nulls, Padding, and Warnings

Previous versions of the ODBC driver turned these items ON by default.

If you encounter the following error

    	Syntax error or access violation
    	State:37000,Native:7134,Origin:[Microsoft][ODBC SQL Server Driver]

and you have Use ANSI Nulls, Padding, and Warnings turned ON, try the following workaround:

1. Open the ODBC Data Source Administrator using the icon in the Control Panel.
2. Select your SQL Server Data Connection and click the Configure button.
3. Click the Options button.
4. Clear the Use ANSI Nulls, Padding and Warnings option.

SQL Debugging Will Be Disabled Following a Lost Server Connection

If the SQL Server against which you are debugging fails during an SQL Debugging Session, you can reestablish the connection to the database. Go to the View menu and use the Refresh command.

SQL Debugging a Disconnected Data Connection May Produce Unexpected Results

If you delete or disconnect a Data Connection during a SQL Debugging session you may find the IDE in an unstable state. It is recommended that you do not delete or disconnect a Data Connection while you are using SQL Debugging. Stop Debugging before you delete or disconnect the Data Connection.

Remote SQL Debugging with Automation Manager Registered as Interactive User

If you install SQL Server and then install Visual C++ Enterprise Edition (including the Visual C++ Enterprise server-side components) on the same computer, the automation manager's identity is registered as "Interactive User." In this scenario, if you log off from this machine but keep SQL server running as a service, you will not be able to remote debug against this server. Registering the automation manager's identity as "Interactive User" necessitates that someone be logged onto the computer to remotely debug SQL.

Visual C++ setup registers the Automation manager as Interactive User, when installed with a preexisting SQL Server, with the assumption that you'll want to do local SQL debugging. SQL Debugging may not work if the automation manager's identity is registered as "Launching User" (the default) and SQL server and automation manager are already running in the service environment.

To change the identity that the automation manager recognizes:

1. From the computer on which you installed SQL Server and then installed Visual C++ Enterprise Edition, run DCOMCNFG.exe .
2. From the Applications list, select Remote Automation CLSID_StubMarshaler
3. Click on the Properties button.
4. Choose the Identity tab.
5. Select the appropriate user account.

Visual C++ Starts Automation Manager but Doesn't Shut it Down

Starting SQL Debugging automatically starts the Automation Manager to manage remote OLE objects. Automation Manager displays the current number of connections and objects that are instantiated on the remote machine. When Visual C++ shut downs, it does not shut down Automation Manager because there isn't any method of querying Automation Manager to determine if another application might also be using it.

You can manually shut down Automation Manager when it displays that there are no connections left.

### Compiler, Linker, Debugger, and MIDL Compiler

Windbg Cannot Use Visual C++ 5.0 Debugging Information.

Because of changes to the format of debugging information in Visual C++ 5.0, you will not be able to use the Windbg debugger (distributed in the NT 4.0 Win32 SDK) to do source level debugging of programs created with Visual C++ 5.0.

_declspec(novtable)

This form of _declspec can be applied to any class declaration, but should only be applied to pure interface classes, i.e. classes that will never be instantiated on their own. The _declspec stops the compiler from generating code to initialize the vfptr in the constructor(s) and destructor of the class. In many cases, this removes the only references to the vtable that are associated with the class and, thus, the linker will remove it. Using this form of _declspec can result in a significant reduction in code size.

_ATL_MIN_CRT and Link Error "unresolved external symbol _main"

When you build a Release version of an ATL project, you can get the following link error:

    LIBCMT.LIB(crt0.obj) : error LNK2001: unresolved external symbol _main

This error occurs if you are using CRT functions that require CRT startup code. The Release configuration defines _ATL_MIN_CRT, which excludes CRT startup code from your EXE or DLL.

To avoid this error, do one of the following:

- Remove _ATL_MIN_CRT from the list of preprocessor defines to allow CRT startup code to be included. On the Project menu, click Settings. In the Settings For: drop down list, choose Multiple Configurations. In the Select project configuration(s) to modify dialog box that appears, click the check boxes for all Release versions, and then click OK. On the C/C++ tab, choose the General category. Remove _ATL_MIN_CRT from the Preprocessor definitions edit box.
- If possible, remove calls to CRT functions that require CRT startup code. Instead, use their Win32 equivalents. For example, use lstrcmp instead of strcmp. Known functions that require CRT startup code are some of the string and floating point functions.

DCOM95 Available for Distributed Applications

The Microsoft Distributed COM (DCOM) files for Windows 95 are useful for creating distributed applications. Some Visual C++ 5.0 samples require DCOM. You can find DCOM95 in the \dcom95 directory on the disc that includes "Microsoft Visual C++" on the label. (Disc 1 if you purchased Visual C++; Disc 3 if you purchased Visual Studio.) Check out the Visual C++ 5.0 Compiler COM support and Active Template Library ( ATL) with DCOM95.

/WS:AGGRESSIVE (Aggressively Trim Process Memory)

Use this linker option to add the WS_AGGRESSIVE attribute to your application's image. The Windows NT 4.0 loader will recognize this attribute and aggressively trim the working set of the process when it is not active. Using this option is similar to adding the following call throughout your application.

    SetProcessWorkingSetSize(hThisProcess, -1, -1)

/WS:AGGRESSIVE can be used for applications that must have a low impact on the system's memory pool.

If the speed of your application is important, do not use /WS:AGGRESSIVE without testing the resulting performance implications. Ideal candidates are processes that tend to operate in the background, such as services and screen savers.

/FD (Generate File Dependencies)

The development environment's build system uses the /FD option to ensure that the most reliable dependency information is used when it builds your project.

_MSC_EXTENSIONS Compiler Macro

This macro is defined unless you compile with /Za for ANSI compatibility. Its value, when defined, is 1.

Option Precedence and the CL Environment Variable

Compiler options are processed "left to right", and when a conflict is detected, the last (right-most) option wins. The CL environment variable is processed before the command line, so in any conflicts between CL and the command line, the command line takes precedence.

/Zm (Specify Memory Allocation Limit)

The compiler uses a number of discrete heaps, each of which has a finite limit. The total of the size limits for all heaps is about 105 MB, but when any one heap is exhausted, the compiler cannot continue. Memory is allocated only as needed; the 105 MB limit is just to keep from using too much memory. Exceeding any one of the discrete-heap size limits occurs only in rare circumstances involving very large or very complex programs. Should your program exceed one of these limits, use /Zm to scale the total size of all the limits. For example, when /Zm200 is specified, the total of all heap size limits is 210MB.

Compiler Now Documents Type Library Dependencies

The compiler provides the full path to any typelib dependency required by the typelib it is currently processing. The path is written, in the form of comments, into the typelib header (.TLH) that the compiler generates for each processed typlib.

If a typelib includes references to types defined in other typelibs, then the .TLH file will include comments of the following sort:

    //

    // Cross-referenced type libraries:

    //

    //  #import "c:\path\typelib0.tlb"

    //

The actual filename in the #import comment is the full path of the cross-referenced typelib, as stored in the registry. If you encounter errors that are due to missing type definitions, check the comments at the head of the .TLH to see which dependent typelibs may need to be imported first. Likely errors are syntax errors (e.g. C2143, C2146, C2321), C2501 (missing decl-specifiers), or C2433 ('inline' not permitted on data declaration) while compiling the .TLI file.

You must determine which of the dependency comments are not otherwise provided for by system headers and then provide an #import directive at some point before the #import directive of the dependent typelib in order to resolve the errors.

Keywords _emul and _emulu Not Documented

Syntax:

_int64

_emul(long, long);

unsigned

_int64 _emulu(unsigned long, unsigned long);

Use these keywords to efficiently multiply two 32-bit integer numbers, which return a 64-bit result.

New Linker Error: Linker Tools Error LNK1189

LIBTOOMANYMEMBERS:: library limit of number objects exceeded

The limit of 65535 objects or members in a library has been exceeded.

Benefit of Using the Linker's /OPT:ICF Option

The /OPT:ICF[,iterations] option removes identical COMDAT records in order to reduce the size of the executable produced by the linker. The iterations value specifies the number of times to repeat the search for identical COMDAT records. If /OPT:REF is specified, /OPT:ICF is on by default unless you specify /OPT:NOICF as well.

Debugging Windows API functions with NT Symbols Loaded

If you have the NT symbols loaded and you want to debug Windows API functions, you need to enter the decorated name of the function while setting a breakpoint on the function. For example, if you want to set breakpoint on the MessageBeep function, use the decorated name _MessageBeep@4. The decorated name can be obtained in the map file created through linker options.

If Screen Flashes During Build or the Wrong Code Page is used When Debugging a Console Application

If you are using Windows 95, delete any of the following files from your computer:

- _DEFAULT.PIF
- DEFAULT.PIF
- CONAGENT.PIF

These files were used by Windows 3.x, and are not needed by Windows 95. If they are used, while you are debugging a console application, the country settings associated with the PIF files will be used, and could result in the wrong code page being loaded. A result of their use on Windows 95 may be screen flashing during a Build, if you have specified console windows to be full screen.

Incorrect Documentation for the Clean Menu Command

The Clean command is incorrectly documented in the "Remove Intermediate Files" topic as follows:

"You can remove all files from the intermediate directories in any project configuration in your project workspace."

In actuality, the Clean command will not remove precompiled header (.PCH) files. This is by design, as the initial generation of .PCH files is time consuming. If the project is a server project that has been registered on the system, the registry entries will not be cleaned up. The final result of the of using the Clean command is to delete all executable (.EXE), dynamic link library (.DLL), and Control (.OCX) files.

MIDL2020: error generating type library: save all changes failed

This error can result if the path to the .IDL file is longer than 126 characters, which is because oleaut32.dll does not currently support path names that are greater than 126 characters. The workaround is to reduce the path to the .IDL file so that it is less than 126 characters.

Error RC2104 : undefined keyword or key name: MFT_STRING

If you encounter this error, open MCL\MFC\Include\AfxRes.h and add the following include directive:

    #include <winresrc.h>

Error Command Line Warning MIDL1009 : unknown argument ignored

MIDL.exe version 3.01.75 generates this error if its arguments are passed in a response file and one of the arguments is an MBCS-character file name that contains a space.

Workarounds

Use a batch file to invoke MIDL with its arguments.
Delete the space from the MBCS file name.

Additional Information on the C2065 Compiler Error

The following information belongs in the tips section of the C2065 compiler error:

Make sure you're using proper namespace scope. For example, in order to properly resolve ANSI C++ Standard Library functions and operators, you must state that you're using the std namespace with the using directive.

For example, unless the using directive is uncommented, the following sample will fail to compile because the cout stream is defined in the std namespace:

    #include <iostream>

    // using namespace std;

    void main()

    {

    cout << "Hello" << endl;

    }

Documentation for Error C2712 Incomplete

The documentation for this error should also contain the following information:

The error can be avoided when using the /GX option by not having local variables or parameters with types that have destructors in a function that uses structured exception handling (SEH). Furthermore, SEH cannot be used in constructors or destructors if using /GX. Code that requires SEH can also be moved to another function in order to avoid the error.

Compiler Warning C2498

    C2498 : "%$S' 'novtable' can only be applied to class declarations"

For example, using __declspec(novtable) with a function, as follows, is illegal:

void __declspec(novtable) f() {

}

Compiler Warning (level 4) C4238

    nonstandard extension used : class rvalue used as lvalue

This error occurs when you are using Microsoft language extensions (/Ze) and use a class type as is an rvalue in a context that implicitly or explicitly takes its address. For example:

    struct C

    {

    C();

    };

    C * pC = &C();	// yields C4238

This usage is not permitted by the C++ Working Paper, and in some cases (such as the example above) can be quite dangerous. This usage is being permitted under /Ze for compatibility with previous versions of the compiler, which did not flag this error. This usage is not permitted under /Za.

Compiler Warning (level 3) C4800

    'type' : forcing value to bool 'true' or 'false' (performance warning)

This warning is generated when some non-bool value is assigned or coerced into type bool. Typically, this message is caused by assigning int varables to bool variables where the int variable contains only values true and false, and could be redeclared as type bool. If you can't rewrite the expression to use type bool, then you can add "!=0" to the expression, which gives the expression type bool. Casting the exrpession to type bool will not disable the warning, which is by design.

Compiler Warning (level 1) C4804

    '%$L' : unsafe use of type 'bool' in operation

This warning is for unary operations and is generated when you used a bool variable or value in an unexpected way. For example, if you use operators such as the negative unary operator (-) or the complement operator (~).

Compiler Warning (level 1) C4805

    '%$L' : unsafe mix of type 'type' and type 'type' in operation

This message is similar to C4804, and it is limited to binary operations. It is generated for operations such as b &= i, b+=i, b/=b, b%=i, etc., where b and i are bool and int respectively .

Compiler Warning (level 1) C4806

    '%$L' : unsafe operation: no value of type 'type' promoted to type 'type' can equal the given constant

This message warns against serious errors such as b == 3, where b has type bool. The promotion rules cause bool to be promoted to int. This is legal according to the ANSI C++ Working Paper, but it can never be true.

Compiler Warning (level 1) C4807

    '%$L' : unsafe mix of type 'type' and signed bitfield of type 'type'

This warning is generated when comparing a one-bit signed bit field to a bool variable. Since a one-bit signed bit field can only contain the values -1 or 0, it is dangerous to compare it to bool. No warnings are generated about mixing bool and one-bit unsigned bitfields since they are identical to bool and can only hold 0 or 1.

Compiler Warnings (level 1) C4808

    case '%d' is not a valid value for switch condition of type 'bool'

This warning occurs if a switch condition is of type bool and one of the case values is outside the range of bool (that is, true and false). Only true, false, 1, 0, and default are valid case values if the switch condition is of type bool

.

Compiler Warning (level 1) C4809

    switch statement has redundant 'default' label; all possible 'case' labels are given

This message is generated in places where you have both 'true' and 'false' cases in addition to a default label.

### Visual SourceSafe Issues

Converting a Project Directly From Source Control

Visual C++ no longer allows you to open an old project from source control and convert it to the new project format from within Visual C++. Use the SourceSafe Explorer (or equivalent source control interface) to get the files to a local disc, then open the project in Visual C++ to do the conversion, and then check the files back in to source control. After this you may open the project out of source control as usual from Visual C++.

Using Visual SourceSafe With Keyword Expansion Disables the Ability to Check In or Add Multiple Files

The keyword expansion feature of Visual SourceSafe disables multiple-file actions for the Check In and Add commands. Using either of these commands with keyword expansion enabled causes only one file to be operated on. The other files are ignored.

### Enterprise Edition Issues

Change in Terminology for Data View and SQL Debugging

In the context of Data View and SQL Debugging in Visual C++ 4.2 Enterprise Edition, the term "Data Source" was used to describe the set of data that a database application accesses. In Visual C++ 5.0 Enterprise Edition, this term was changed to "Data Connection" to be consistent with terminology used across Visual Studio Products.

Database Projects

In Visual C++ 4.2 Enterprise Edition, you could add a Data Connection to any type of Visual C++ project by selecting Data Connection from the Insert menu.

In Visual C++ 5.0 Enterprise Edition, a new project type has been created to allow more effective management of Data Connections. The new project type is called a Database Project. Data Connections can only be added to Database Projects by selecting Add to Project, then Data Connection from the Project menu.

For more information about working with Database projects, see the following sections of the online documentation:

- Working with Database Projects in the Visual Database Tools node
- Microsoft Visual Database Tools Overview in the Visual Database Tools node
- Data View in the Developer Studio Environment User's Guide

Default or Identity Values Are Not Displayed When You Enter New Records into a Table

To display these values, requery the table by choosing Run from either the Query toolbar or from the Tools menu.

Converting VC 4.2 Projects When the Data Connection is Offline

Opening a Visual C++ 4.2 project that contains a data connection in the Visual C++ 5 development environment will attempt to create a workspace that contains the converted project and a database project that contains the data connection. If the database that the data connection refers to is offline, error messages will be displayed and the database project will not be created.

Workaround

Manually add a database project that refers to the appropriate data connection.