Converting 16-bit 'C' to 32- bit c++/vc++..??

b_harpal used Ask the Experts™

I have an application code written in 'C' for DOS.
Now i want to port this code for windows OS. There are quite a few hurdles. First the entire code is very vast.
2) VC++ compiler does'nt support lots of 'C' header files.

Any suggestions..????

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®


The application is graphics based..
i would suggest that u start converting your structured C code into object oriented C++ code first and then use MFC in VC++ and then proceed with debugging n stuff

i would say converting dos based program to windows is a project that requires lots of resources and time, especially so when the program is big.

i have a few suggestions here that you may like to consider.

- first, model the app gui interface using an object language of ur choice.

e.g. suppose that ur app has a menu bar with the menu options File, Edit, Help. also it has a text area to type in which on the side of the text area has a vertical scrollbar. Writing it down:

--- Menu Bar
 |----- File (SubMenu)
 |  |------ New (Menu Item)
 |  |------ Open (Menu Item)
 |  |------ Save (Menu Item)
 |  |------ Exit (Menu Item)
 |----- Edit (SubMenu)
 |  |------ Cut (Menu Item)
 |  |------ Copy (Menu Item)
 |  |------ Paste (Menu Item)
 |----- Help (SubMenu)
    |------ About (Menu Item)

--- Text Area
 |----- Vertical Scrollbar

this forms part of the requirement analysis of the project. in converting the app to windows, you will have to stick to this interface. You have to modify this interface model now if you want to change the interface of the original program slightly.

- next, we have to model the behavior of the app.

suppose we are modelling the old dos edit program.

A basic text editor...(blah blah blah)


Menu Bar:
Is the main interface to access the different functions of the program

Contains all file-related options such as New, Open, ...

Creates a blank document. Clear the text area.

Show a Open File Dialog to let the user choose the file. Upon choosing the file, open the file, read the contents and copy it to the text area

and so on and so forth...

- the next step is to reiterate the first two steps again. this is neccessary as we write the behaviour model, we introduce more objects into the object model.

- now that we have the basic behaviour model, we are going to enhance it in terms of view of a programmer.

e.g. Taking File-New,

- creates a new text buffer to represent the new document
- updates the window list to include this document
- set the active window as this document
- copy the content of the text buffer to the text area
- focus on text area

for this part, you can probably get it from the code. the idea is to go into as much details as possible without going down to the hard core details. Possibly this is better achieved when you understands how a program works in windows. Oh yes, because your original dos program is already so huge and is largely requires many changes to convert it to a windows app, this step helps to set your focus and not be distracted by the source code.

- now what we have to do is to finally look at the source code that you have. we are going to list all the functions and structures, variables separately in their own list.

for e.g.

void somefunc(char somechar);
  - this function takes in a char and display it to the
    text area

  - this structure is used to record down what is the
    previous action, and the current undo level

  - this variable has a global scope. It is used to
    indicate the window that we are currently viewing

- now that we have a list of functions, structures, and variables, we need the comprehensive details of each functions, structures, and variables

* note: the above steps is usually done in the process of developing the dos program. in case where the documentation is lost, you have to come up with this, not only to aid converting the program but also for future use. in the case which you already have the documentation, these few steps is not required and can be skipped.

CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

If your application works directly with hardware (graphic card) then you will have alot of problems with win2k. You'll need to convert all the graphics to work with the windows drivers (and directx).
that's y i suggest the above steps, by abstracting it then rewriting it in win32


It uses Graphics VGA as shown below.
Is it that i really don't have any other option left..??



void Initialize(void)
  int xasp, yasp;               /* Used to read the aspect ratio*/
  registerbgidriver( EGAVGA_driver);     /* egavga driver linked in */
  registerbgifont(small_font);           /* Stroked font linked in */

  GraphMode = VGAHI;
  GraphDriver = VGA;
  initgraph( &GraphDriver, &GraphMode, "" );
  ErrorCode = graphresult();          /* Read result of initialization*/
  if( ErrorCode != grOk ){          /* Error occured during init     */
    printf(" Graphics System Error: %s\n", grapherrormsg( ErrorCode ) );
    exit( 1 );

  getpalette( &palette );          /* Read the palette from board     */
  MaxColors = getmaxcolor() + 1;     /* Read maximum number of colors*/

  MaxX = getmaxx();
  MaxY = getmaxy();               /* Read size of screen          */

pardon me, but y would u want to convert to windows?

This question didn't show any activity for more than 21 days. I will ask Community Support to close it unless you finalize it yourself within 7 days.
You can always request to keep this question open. But remember, experts can only help if you provide feedback to their comments.
Unless there is objection or further activity,  I will suggest to accept


comment(s) as an answer.

thanks for accepting me :D

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial