Mukesh Pareek Mukesh Pareek - 8 months ago 41
C Question

How to run a Videofile using VLC player Using C++



int main()
_chdir`("C:\\Program Files (x86)\\VideoLAN\\VLC");
system("vlc C:\\Users\\Documents\\Wildlife.wmv");

return 0;

By using the above code i am successfully able to run the video using vlc player but as the video finishes,still the VLC player window doesn't get close.How to shut the VLC player window?

Please post your valuable suggestion


Use CreateProcess to pass the correct commandline. See the example below. Note the use of \" separators.

#include <Windows.h>

int main()
    const char *appname = "c:\\Program Files (x86)\\VideoLAN\\VLC\\vlc.exe";
    const char *filename = "c:\\files\\my file.wav";

    memset(&si, 0, sizeof(si));
    si.cb = sizeof(si);
    memset(&pi, 0, sizeof(pi));

    char buf[MAX_PATH + 300];
    wsprintfA(buf, "%s \"%s\" --play-and-exit", appname, filename);
    CreateProcessA(0, buf, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);

    return 0;

Use Unicode if that's a proper Windows program.