Embedding a DOS console in a windows form

前端 未结 3 1287
盖世英雄少女心
盖世英雄少女心 2020-11-27 16:34

Is it possible to embed a DOS console in a Windows Form or User Control in C# 2.0?

We have a legacy DOS product that my Windows app has to interact with, and it\'s b

3条回答
  •  -上瘾入骨i
    2020-11-27 16:51

    Concerning your question on how to display the DOS app inside the Windows app.

    There are a few solutions.

    • The first one is to simply not display the DOS app (with CreateNoWindow) and "simulate" the UI of the DOS app in your Windows application by reading and writing to the streams.

    • The other solution would be to use the Win32API, get the Windows Handle (Whnd) of the Console/DOS application window and set its parent to your form. I'm currently not at home and since it has been ages since I've done this, I can't remember by heart how it is done. If I'm not mistaken you'll need to use the following Win32 API calls:

      • FindWindow
      • GetWindow
      • SetParent

    If I have some time left later today, I'll see if I can find better samples.

提交回复
热议问题