Fix skins ditribution for win32
[vlc/vlc-acra.git] / bin / winvlc.c
blobef31d988025d756f0d1990ef5e7accd76c1392e2
1 /*****************************************************************************
2 * winvlc.c: the Windows VLC player
3 *****************************************************************************
4 * Copyright (C) 1998-2008 the VideoLAN team
6 * Authors: Vincent Seguin <seguin@via.ecp.fr>
7 * Samuel Hocevar <sam@zoy.org>
8 * Gildas Bazin <gbazin@videolan.org>
9 * Derk-Jan Hartman <hartman at videolan dot org>
10 * Lots of other people, see the libvlc AUTHORS file
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25 *****************************************************************************/
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
31 #define UNICODE
32 #include <vlc/vlc.h>
33 #include <string.h>
34 #include <stdio.h>
35 #include <stdlib.h>
36 #include <windows.h>
38 static char *FromWide (const wchar_t *wide)
40 size_t len;
41 len = WideCharToMultiByte (CP_UTF8, 0, wide, -1, NULL, 0, NULL, NULL);
43 char *out = (char *)malloc (len);
44 if (out)
45 WideCharToMultiByte (CP_UTF8, 0, wide, -1, out, len, NULL, NULL);
46 return out;
50 int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
51 #ifndef UNDER_CE
52 LPSTR lpCmdLine,
53 #else
54 LPWSTR lpCmdLine,
55 #endif
56 int nCmdShow )
58 int argc, ret;
59 wchar_t **wargv = CommandLineToArgvW (GetCommandLine (), &argc);
60 if (wargv == NULL)
61 return 1;
63 char *argv[argc + 1];
64 for (int i = 0; i < argc; i++)
65 argv[i] = FromWide (wargv[i]);
66 argv[argc] = NULL;
67 LocalFree (wargv);
69 libvlc_exception_t ex, dummy;
70 libvlc_exception_init (&ex);
71 libvlc_exception_init (&dummy);
73 /* Initialize libvlc */
74 libvlc_instance_t *vlc;
75 vlc = libvlc_new (argc - 1, (const char **)argv + 1, &ex);
76 if (vlc != NULL)
78 libvlc_add_intf (vlc, NULL, &ex);
79 libvlc_playlist_play (vlc, -1, 0, NULL, &dummy);
80 libvlc_wait (vlc);
81 libvlc_release (vlc);
84 ret = libvlc_exception_raised (&ex);
85 libvlc_exception_clear (&ex);
86 libvlc_exception_clear (&dummy);
88 for (int i = 0; i < argc; i++)
89 free (argv[i]);
91 (void)hInstance; (void)hPrevInstance; (void)lpCmdLine; (void)nCmdShow;
92 return ret;