Q and A program

This is a discussion on Q and A program within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by LeLouche008 Thanks King Mir, does anyone know how i can open an mp3 file sitting on my ...

  1. #16
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by LeLouche008 View Post
    Thanks King Mir, does anyone know how i can open an mp3 file sitting on my desktop with a c++ program. i don't want the program to play it for me, i just want windows media player to do it. same effect as double clicking the file.
    This probably belongs in a separate thread (and for the 15 months or so I've been a member here, it's been asked about 20-50 times).

    In Windows, you'd use "ShellExecute" - look that up on msdn.microsoft.com

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  2. #17
    Registered User
    Join Date
    Sep 2008
    Posts
    8
    Code:
    #include "windows.h"
    #include "iostream.h"
     
    int main()
    {
    char input;
    cin.get(input);
    ShellExecute(NULL, "open", "hello.txt", "input", "C:\Documents and Settings\Administrator\Desktop\Alpha\hello.txt", SW_HIDE);
    return 0;
    }
    all i get is an empty console screen... can anybody help me with the shellexecute codes, i just want to open a text file.

  3. #18
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    According to MSDN:
    4. If parameter 3 is a file, parameter 4 must be NULL.
    5. This is the working directory. "C:\Documents and Settings\etcetera\hello.txt" is not a directory, it is a file. Also, backslashes need to be escaped, like "C:\\Documents and Settings\\etcetera", which is why you're getting all those warnings about nonsense escape characters.
    6. SW_HIDE says to immediately hide the notepad window.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21