Copyright: MIGRATE.HLP, Ver 1.00.3195


Contents
Questions about Moving to Visual C++

The questions in this help file represent some of the typical questions developers ask about moving to Visual C++ for Windows and Windows NT, 32-Bit Edition.

Moving from Visual C++ for Windows

 How do I port 16-bit applications to 32 bits?

 What's different in the 32-bit edition of Visual Workbench?

 What's different in the 32-bit edition of App Studio?

 What's different in the 32-bit edition of the Microsoft Foundation Class Library?

 Can I convert 16-bit projects into 32-bit projects?

 Can I use VBX custom controls with Visual C++ for Windows NT?

 How do I build 16-bit applications from Windows NT?

 How do I build 32-bit applications from Visual C++ for Windows?

 Can I build 32-bit applications from MS-DOS?

 Can I use the 16-bit Visual Workbench under Windows NT?

Moving from the Win32 Software Development Kit and Device Driver Kit

What are the major differences between Visual C++ for Windows NT and the SDK compiler and utilites?

 How do I override the system paths that point to the Win32 SDK?

 How do I move my Win32 SDK source files to Visual C++?

 How do I use my Win32 SDK makefiles with Visual C++?

 How do I migrate my Win32 SDK project to use Visual C++ internal makefiles?

 How can I modify the header of a 32-bit executable file?

 How do I build device drivers with Visual C++?

 Can I write POSIX or OS/2 applications using Visual C++ for Windows NT?


Q. How do I port 16-bit applications to 32 bits?

A. The Visual C++ for Windows NT documentation describes porting 16-bit applications.

Migrating 16-bit Microsoft Foundation Class Library (MFC) applications is described in "Microsoft Foundation Class Library Update" in the Class Library Reference.

Porting 16-bit applications for Windows to Win32, is covered in "Porting 16-bit code to 32-bit Windows" in Programming Techniques.

Applications that use standard I/O calls such as printf and scanf can be built as Console applications under Windows NT. Function compatibility is described in the C Run-Time Library Reference.


Q. What's different in the 32-bit edition of Visual Workbench?

A. The Visual Workbench in Visual C++ for Windows NT has the following additions:

32-bit Project types

Compiler and linker options for 32-bit build tools

Integrated Source Profiler

"Find in Files" multiple-file search capability

Multithread debugging capability

Win32 Structured Exception Handling debugging

Break command on the Debug menu

Memory window in the debugger

Generalized output window that accepts output from custom tools added to the Tools menu

Stop command on the tools menu that will also stop build tools

Initialization and configuration information is stored within the configuration registry instead of MSVC.INI.

There are also some option differences in the Editor, Colors, Tools, and Debug dialog boxes.


Q. What's different in the 32-bit edition of App Studio?

A. App Studio for Windows NT has the following differences:

VBX custom controls are not supported

App Studio for Windows NT cannot load and save 32-bit executable files (.EXE), dynamic-link libraries (.DLL), or resource files (.RES).

App Studio for Windows NT stores information about initialization and configuration within the configuration registry instead of APSTUDIO.INI.

Note  App Studio for Windows NT supports only resources and resource objects that are common to Microsoft Windows and Windows NT.

For more information, see "App Studio Update" in the App Studio User's Guide.


Q. What's different in the 32-bit edition of the Microsoft Foundation Class Library?

A. The Microsoft Foundation Class Library shields the programmer from most of the changes brought about by moving to Win32. Only the message handlers CWnd::OnCommand and CWnd::OnParentNotify and the CTime class have changed. Also, there is no support for VBX controls, the Microsoft Windows for Pen Computing extensions, or AFXDLL (MFC200.DLL or MFC200D.DLL).

For more information, see "Microsoft Foundation Class Library Update" in the Class Library Reference.


Q. Can I convert 16-bit projects into 32-bit projects?

A. Yes. If you are converting your application to you can use the CVTMAKE sample program to convert your project files to work as internal makefiles.

CVTMAKE is ready to compile in the \MSVCNT\SAMPLES\CVTMAKE. See CVTMAKE.WRI in the same directory for more information.


Q. Can I use VBX custom controls with Visual C++ for Windows NT?

A. VBX custom controls are 16-bit dynamic-link libraries and therefore can only be used with 16-bit applications.


Q. How do I build 16-bit applications from Windows NT?

A. If you have both Visual C++ for Windows, Version 1.0 and Visual C++ for Windows NT installed on your machine, you can develop 16-bit Windows and MS-DOS applications from the Visual Workbench or from the command line.

The BETA2FIX utility modifies the command-line tools from Visual C++ for Windows to run under Windows NT. You need to perform this procedure this only once.

To make the command-line tools from Visual C++ for Windows available under Windows NT:

1.	Make sure that BETA2.DLL is in your path. This DLL is required to run the patched tools.

2.	Copy the contents of the directory containing 16-bit Visual C++ executable files (by default, \MSVC\BIN) to a new directory.

3.	Move to this new directory, and enter BETA2FIX /V *.EXE

To build 16-bit applications from the Visual Workbench:

1.	Convert the command-line tools as described above.

2.	Start the Visual Workbench from Visual C++ for Windows NT.

3.	From the Options menu, choose Directories. Update the paths to point to the 16-bit version of each (the "Executable Files Path" should point to the directory containing the executables that were modified with the BETA2FIX utility).

4.	From the Project menu, choose Open. Select the "Use as an external makefile" option and load your project makefile.

5.	Build and execute the program as usual.

Note  Visual C++ for Windows NT cannot debug 16-bit executable files, though the Win32 SDK WinDbg debugger will. In addition, context-sensitive keyword help does not work.

To convert the patched 16-bit tools back, so that they can be used from Windows 3.1 and MS-DOS again:

1.	From the Windows NT command line, move to the directory containing the patched 16-bit Visual C++ executable files.

2.	Enter BETA2FIX /U *.EXE


BETA2FIX.EXE and BETA2.DLL are available in the B2FIX.EXE self-extracting archive from the following sources:

CompuServe

Download from Library 1 of the MSLNG32 or MSLANG forum.

Internet (via FTP)

Download from FTP.UU.NET in the /vendors/microsoft/visual-tools directory.

Microsoft Developer Network (MSDN) CD-ROM

Copy from the "Unsupported Tools" category on the Fall 1993 and later CDs.

Microsoft Download Service (MSDL):

Download from the "C/C++ and Quick C" section under "Languages and Windows SDK".

To access MSDL, call (206) 936-MSDL in the United States (contact local subsidiary for other countries). MSDL supports modems with the following characteristics: 1200/2400/9600 baud, 8 bits, no parity, 1 stop bit (8N1).


Q. How do I build 32-bit applications from Visual C++ for Windows?

A. If you have both Visual C++ for Windows, Version 1.0 and Visual C++ for Windows NT installed on your machine, you can develop applications for Win32 and Win32s:

1.	From MS-DOS, set up the Win32s subsystem by running the setup program in the \MSVC32S directory of the installation CD-ROM. You only need to do this once.

2.	Start Windows 3.1 and run the Visual Workbench from Visual C++ for Windows.

3.	From the Options menu, choose Directories. Update the paths to point to the 32-bit version of each.

4.	From the Project menu, choose Open. Select the "Use as an external makefile" option and load your project makefile.

5.	Build and execute the program as usual.

Note  Visual C++ for Windows cannot debug 32-bit executable files. Instead use CodeView for Win32s (CVW32S.EXE). In addition, context-sensitive keyword help does not work


Q. Can I build 32-bit applications from MS-DOS?

A. Yes. All of the command-line tools provided with Visual C++ for Windows NT are MS-DOS extended. They can be run directly from the MS-DOS command prompt and do not require a separate DOS extender or memory manager.

Before building a 32-bit application, you should to set the INCLUDE, LIB, and PATH environment variables to point to the directories containing the 32-bit versions.


Q. Can I use the 16-bit Visual Workbench under Windows NT?

A. Do not attempt to run the 16-bit Visual Workbench from Visual C++ for Windows version 1.0 under Windows NT. Certain operations, such as building, will not work or are unstable. Use the 32-bit version of Visual Workbench instead.


Q. How do I override the system paths that point to the Win32 SDK?

A. If you installed the Win32 SDK for Windows NT while logged in as Administrator, the SDK Setup program modifies your System (rather than User) environment variables. If you then install Visual C++ for Windows NT at the user level, path conflicts will occur, since system environment variables are set before user environment variables.

To clear the appropriate system paths:

1.	Log onto Windows NT as Administrator.

2.	Start the REGEDT32 program.

3.	Select the HKEY_LOCAL_MACHINE window.

4.	Expand the following sub-folders in order:

1.	System

2.	CurrentControlSet

3.	Control

4.	Session Manager

5.	Environment

5.	Remove the path entry that points to the Win32 SDK executable files by double-clicking the "Path" string in the right-hand split window. The String Editor dialog box appears. Delete only the section of the path string which points to the Win32 SDK subdirectory. The section to delete will look similar to the following:

;c:\mstools\bin

Do not delete any other sections of this path string. When you are finished, choose OK.

6.	Remove the entry that points to the Win32 SDK library files by double-clicking the "Lib" string in the right-hand split window. Again, the String Editor dialog box appears. Clear the contents of this dialog box and choose OK.

7.	Remove the entry that points to the Win32 SDK include files by repeating step #5 for the "Include" string.

8.	Close REGEDT32. This saves the new registry entries.

9.	Restart Windows NT to use the new paths.


Q. How do I move my Win32 SDK source files to Visual C++?

A. In the vast majority of cases, no changes need to be made. You'll need to make changes only in the following special situations:

Use the double-underscore keywords __try, __except, __finally, and __leave instead of try, except, finally, and leave, or else add your own #define statements.

The SDK header file EXCPT.H defines try, except, finally, and leave as their double-underscore counterparts, which are the actual keywords. These definitions have been removed from Visual C++ for Windows NT, to avoid conflicts with the ANSI specification.

In header files, use the push and pop syntax when you use #pragma pack.

The compiler issues a warning when a header file changes pack size, but header files from the Win32 SDK turn this warning off. The Visual C++ header files use the push and pop feature to save and restore the existing pack size and do not turn this warning off. As a result, if you have a header file that changes default pack size, this warning may appear.

To avoid this warning, use #pragma pack(push, identifier, n) and #pragma pack(pop, identifier) instead of #pragma pack(n) and #pragma pack(). See the C Language Reference for more information on these pragmas.

Examine code that uses the localeconv function, checks for the return value of CHAR_MAX, and is compiled with the /J command-line option. With Visual C++ for Windows NT, if you use the /J compiler option, localeconv will return CHAR_MAX as 255 instead of 127.

The localeconv function from the Win32 SDK returns an error value 127, independent of the /J command-line option, which makes unsigned characters the default. In Visual C++ for Windows NT, the /J command-line option will adjust the return value to match the new value of CHAR_MAX.


Q. How do I use my Win32 SDK Makefiles with Visual C++?

A. Update your SDK makefiles and then run the makefiles from the command line or as an external project in Visual Workbench. In general, the following changes need to be made:

Remove calls to the CVTRES and CVTOMF utilities.

These are tools in the SDK which convert .RES files (output from RC) and 32-bit OMF object files (typically from MASM) to COFF format for the linker. These utilities are obsolete, because the Visual C++ linker can link the .RES and OMF .OBJ files directly.

Replace any occurrences of CRTDLL.LIB with MSVCRT.LIB.

In the SDK, the DLL version of the C run-time library is supported with the import library CRTDLL.LIB. In Visual C++ for Windows NT, the import library and DLL are MSVCRT.LIB and MSVCRTnn.DLL, where nn is the version number of the DLL (currently 10).

For DLLs with no entry point, add the /noentry option to the LINK command line.

With the Windows NT SDK, if a DLL is linked without the /entry option, the DLL will be created with no entry point. In Visual C++ for Windows NT, the default for DLLs is to use the entry point _DllMainCRTStartup, which will automatically initialize the C run-time library.

When building libraries with debugging information for distribution, use the /Z7 compiler option instead of /Zi.

The Visual C++ for Windows NT compiler and linker use program database (PDB) files to speed linking. The /Z7 option causes the compiler and linker to merge the PDB information into the object, library and executable files; this is the same behavior as the Win32 SDK tools.

Optionally, remove the trailing "32"  and "386" from LINK and CL.

With Visual C++ for Windows NT, the "stub" utilities LINK32 and CL386 execute LINK and CL, respectively, and print a warning message. The actual linker and driver have been renamed to LINK and CL, but the stub utilities are included for makefile compatibility. You can slightly reduce your build time by calling the actual utilities directly.


Q. How do I migrate my Win32 SDK makefiles to Visual C++ internal makefiles?

A. Visual Workbench reads makefiles and presents projects through a visual interface. Normally, you build a project from scratch, using Visual Workbench commands, and Visual Workbench builds a makefile (.MAK) for you. However, you can always look at the underlying .MAK file. To see what format makefiles should have to work most naturally as projects, you should examine project makefiles built by Visual Workbench and use them as models.

For information on creating projects, see Using Projects in the Visual Workbench Help. For information on compiler and linker options, see Build Tools Help.


Q. What are the major differences between Visual C++ 32-Bit Edition and the SDK compiler and utilites?

A. With few exceptions, the compiler, utilities, and run-time library support the same behavior. However, the Visual C++ utilities have new features for better usability and error detection. For information on new features, see the documentation on individual utilities. For specific changes you might need to make, see other questions in this category.

Visual C++ for Windows NT provides a complete set of well-tested and documented tools for the development of Win32 and Win32s applications. You can write most applications without the Win32 SDK, but in a few cases you may need to use some tools from the Win32 SDK with Visual C++ . The table below outlines some differences between the tool sets.

Table of Win32 SDK and Visual C++ Tools

Win32 SDK	Visual C++
API Profiler	Source Profiler
BIND	EDITBIN /BIND
CVTRES	Incorporated into LINK
CVTOMF	Obsolete
Dialog Editor	App Studio
Image Editor	App Studio
Font Editor	None
M Editor	Visual Workbench
MASM	MASM 6.1.1 (Separate product)
Microsoft Test	Future product
NTSD	Visual Workbench
OLE 2.0 Toolkit (Beta)	None
RPC toolkit	None
REBASE	EDITBIN /REBASE
Setup Toolkit	None
Spy	SPY++
SYMEDIT	None
WinDbg	Visual Workbench and CodeView for Win32s
Working Set Tuner	None


Q. How can I modify the header of a 32-bit executable file?

A. EDITBIN.EXE lets you modify the header of a 32-bit .EXE, .DLL, or .OBJ file. To examine 32-bit executable files, use the DUMPBIN tool. EDITBIN is described in  \MSVCNT\HELP\EDITBIN.WRI, and DUMPBIN is described in the Build Tools User's Guide.

These tools replace the /edit and /dump options from the SDK linker.


Q. How do I build device drivers with Visual C++?

A. Although Visual C++ does not supply all of the libraries, headers, and tools needed to create device drivers for Windows NT, you can still use many Visual C++ components.

1.	Update the command-line tools included with the DDK with the versions provided with Visual C++.

Note  Not all of the tools provided in the DDK (such as MASM) are supplied with Visual C++, so be careful when deleting files.

2.	Make appropriate changes to the source files and makefile.

See

How do I migrate my Win32 SDK source files to Visual C++?

How do I use my Win32 SDK makefiles with Visual C++?

3.	Use the BUILD or NMAKE utility to build the device driver.


Q. Can I write POSIX or OS/2 applications using Visual C++ for Windows NT?

A. The current version of Visual C++ is designed to develop applications for the Win32 and Console subsystems. However, if you install the POSIX headers and libraries from the Microsoft Win32 Software Development Kit, you can use Visual C++ for Windows NT to write POSIX applications. The Visual Workbench does not allow POSIX debugging.

OS/2 program development is not supported.


Q. Does Visual C++ for Windows NT target the Silicon Graphics MIPS or Digital Equipment Alpha platforms?

A. No, only Intel-compatible microprocessors are supported with this version of Visual C++ for Windows NT.


Copyright Notice
Copyright Notice for Moving to Visual C++

Information in this document is subject to change without notice. Companies, names, and data used in examples herein are fictitious unless otherwise noted. No part of this document may be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without express written permission of Microsoft Corporation.

© 1993 Microsoft Corporation. All rights reserved.

Microsoft is a registered trademark and Windows and Windows NT are trademarks of Microsoft Corporation.

DEC is a registered trademark of Digital Equipment Corporation.

Silicon Graphics and MIPS are registered trademarks of Silicon Graphics, Inc.