Results 1 to 4 of 4

Thread: DOS Based??

  1. #1

    Thread Starter
    Frenzied Member macai's Avatar
    Join Date
    Jul 2001
    Location
    Napanoch NY
    Posts
    1,228

    DOS Based??

    Hay! I, in memory of Quick Basic want to write a program that is DOS based. So you can type in <myexe> -<mycommands> and it will do as commanded. Anybody know how to do this? If you do, i would like this data.
    Luke

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    You can't make a DOS program with VB.
    You can however create a 32-bit console application which is not really the same thing.
    A DOS app is a 16-bit program while a Windows Console app is 32-bit and can also use the Windows API functions something a DOS program never can do.
    The main difference is that you can't run this from DOS, i.e Windows must be started.

    Most people would say that a DOS app and a 32-bit console app is the same thing because they look the same but that is not true.

    You can use a consol by calling some of the consol API functions like GetStdHandle to retrieve handles for StdOut and StdIn.
    WriteConsol to write to StdOut.
    ReadConsol to read from StdIn.
    You might also need the following API functions:
    GetConsoleScreenBufferInfo
    GetConsoleCursorInfo
    GetConsoleMode
    SetConsoleMode

    You might also need to write your own callback function to handle cases when the user press Ctrl+C or Ctrl+Break.
    You'll use SetConsoleCtrlHandle for this.

    You'll also need to handle redirection yourself so for example if the user types:
    YourAppName >c:\MyFile.txt
    All outputs are redirected to C:\MyFile.txt

    But even after you have done all this it's not enough because when you compile the application VB will compile it as a windowing application.
    Even though you're creating a console and writes all output to this console your application will create a new console and not use the one that started your application.
    To use the current console you have to change the header in your EXE file.
    Attached is a small program you can use on your exe to change it from a windowing app to a console app.

    Best regards
    Attached Files Attached Files

  3. #3

    Thread Starter
    Frenzied Member macai's Avatar
    Join Date
    Jul 2001
    Location
    Napanoch NY
    Posts
    1,228

    Help...

    I dont understand how i can use these APIs. Is there any possibility that you give me a more....definitive use for all these APIs? I know that they are useful. Just dont know how to use them. Can you post some quick instructions on what these API calls' use is and how to use them?
    Luke

  4. #4
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Here's a sample application.
    If you compile this then run MkConsole.exe on it.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width