Re: MCI Devices in Console Apps

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Kralizec (anonymous_at_discussions.microsoft.com)
Date: 03/19/04

  • Next message: William DePalo [MVP VC++]: "Re: MCI Devices in Console Apps"
    Date: Thu, 18 Mar 2004 16:01:06 -0800
    
    

    Thanks for all the help. It will be very useful. By the way, I also found you can leave out the MCI_NOTIFY and MCI_WAIT altogether and use MCI_STATUS to poll the device. I do have one more question for you, though.

    If it's possible to create Windows in a console applications (using main instead of WinMain) then why, in MS VC++, when I'm working on a console app, don't the function reference tips pop up for functions such as RegisterClass and CreateWindow. But when I'm writing a Windows app, using WinMain, they do pop up?

    ----- William DePalo [MVP VC++] wrote: -----
         
         "Kralizec" <anonymous@discussions.microsoft.com> wrote in message
         news:57B57191-BF2C-4E75-96FD-13D128BF1769@microsoft.com...
    > I'd like to create a console application that uses audio CDs.
    > This is a bit more difficult than it seems at face value. The
    > MCI_WAIT and MCI_NOTIFY system used with
    > mciSendString and mciSendCommand is giving me trouble.
         
         MCI is over a decade old. It was released at a time when there were no true
         console applications, just DOS applications that ran under a different VM
         than 16 bit Windows.
         
    > If I use MCI_WAIT to wait until playback finishes,
    > the only control I can give the user is the ability to
    >press a break key to stop waiting. And I can't use
    > MCI_NOTIFY in a Console application because I
    > don't have a window handle to pass.
         
         There is no law that says that a console program can't have a window.
         Similarly there is no law that says a non-console application must display
         windows.
         
    > So how can I create a versatile program that uses audio CDs, given these
         limitations?
         
         So, you have at least two ways to use MCI. Your console application can
         create windows and spin a message loop (on 2K and XP you might want to check
         the docs for the meaning of the HWND_MESSAGE flag which creates invisible,
         message-only windows) or you can build a gui application by replacing main()
         with WinMain() and simply choose not to display the window(s) that you
         create.
         
    > Is there another set of commands, different from the MCI commands, that I
         should use?
         
         It turns out the both the 9x platforms and NT platform (NT/2K/XP/2K+3)
         provide an ASPI-like interface that permits device control by sending SCSI
         like commands, even in the case where the device is ATAPI.
         
    > Will I have to interact directly with the CD-ROM drivers? If so, how do I
         do that?
         
         Do a google search for SendASPI32Command() for information on the barely
         documented ASPI interface for 9x.
         
         For NT/2K/XP/2K+3 you can look at the SPTI (SCSI pass-through interface)
         sample in the device driver kit. If I remember correctly, to use SCSI you
         need admin privileges.
         
         Regards,
         Will


  • Next message: William DePalo [MVP VC++]: "Re: MCI Devices in Console Apps"

    Relevant Pages

    • Re: list
      ... go about mastering Tcl ?? ... Tcl has a wonderful feature called the console. ... It's easiest to use if you are working on windows. ... which you can modify with various tk commands. ...
      (comp.lang.tcl)
    • Re: WinXP boot disk, WinXP DOS
      ... traditional commands if I am in a DOS session in Windows, ... There is a 32-bit command console. ...
      (microsoft.public.windowsxp.general)
    • Re: A way to wait Python event
      ... > launch the console was showed and exited on Windows. ... then execute commands from a proper shell. ... I believe what you expirience has nothing to do with python ...
      (comp.lang.python)
    • Re: CreateProcessAsUser - Process starts then exits
      ... Windows XP Media Center ... public Int32 dwX; ... public IntPtr lpReserved2; ... parent's console. ...
      (microsoft.public.win32.programmer.kernel)
    • Re: CreateProcessAsUser - Process starts then exits
      ... service most likely runs in a separate invisible session. ... the program I was trying to start was a windows forms app I ... public IntPtr lpReserved2; ... parent's console. ...
      (microsoft.public.win32.programmer.kernel)