Thread: Q and A program

  1. #16
    Kernel hacker
    Join Date
    Jul 2007
    Farncombe, Surrey, England
    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

    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
    #include "windows.h"
    #include "iostream.h"
    int main()
    char 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
    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.

Popular pages Recent additions subscribe to a feed