- plugin fix on windows

This commit is contained in:
Mark Vejvoda 2012-05-12 23:47:16 +00:00
parent ec2a708603
commit 69c1de284c
1 changed files with 48 additions and 9 deletions

View File

@ -154,33 +154,72 @@ void VideoPlayer::PlayVideo() {
*/
libvlc = libvlc_new(vlc_argc, &vlc_argv[0]);
if(libvlc == NULL) {
// For windows check registry for install path
#if defined(WIN32) && !defined(__MINGW32__)
// example from: http://stackoverflow.com/questions/1387769/create-registry-entry-to-associate-file-extension-with-application-in-c
//[HKEY_CURRENT_USER\Software\Classes\blergcorp.blergapp.v1\shell\open\command]
//@="c:\path\to\app.exe \"%1\""
//[HKEY_CURRENT_USER\Software\Classes\.blerg]
//@="blergcorp.blergapp.v1"
//Open the registry key.
wstring subKey = L"Software\\VideoLAN\\VLC";
HKEY keyHandle;
DWORD dwDisposition;
LONG lres = RegOpenKeyEx(HKEY_LOCAL_MACHINE,subKey.c_str(),0, KEY_READ, &keyHandle);
if(lres == ERROR_SUCCESS) {
std::string strValue;
//GetStringRegKey(keyHandle, L"", strValue, L"");
WCHAR szBuffer[4096];
DWORD dwBufferSize = sizeof(szBuffer);
ULONG nError = RegQueryValueEx(keyHandle, "", 0, NULL, (LPBYTE)szBuffer, &dwBufferSize);
if (ERROR_SUCCESS == nError) {
strValue = szBuffer;
}
RegCloseKey(keyHandle);
if(strValue != "") {
#if defined(WIN32)
_putenv("VLC_PLUGIN_PATH=c:\\program files\\videolan\\plugins");
strValue = "VLC_PLUGIN_PATH="strValue;
_putenv(strValue.c_str());
#else
setenv("VLC_PLUGIN_PATH","c:\\program files\\videolan\\plugins",1);
setenv("VLC_PLUGIN_PATH","c:\\program files\\videolan\\vlc\\plugins",1);
#endif
libvlc = libvlc_new(vlc_argc, &vlc_argv[0]);
}
}
#endif
libvlc = libvlc_new(vlc_argc, &vlc_argv[0]);
if(libvlc == NULL) {
#if defined(WIN32)
_putenv("VLC_PLUGIN_PATH=\\program files\\videolan\\plugins");
_putenv("VLC_PLUGIN_PATH=c:\\program files\\videolan\\vlc\\plugins");
#else
setenv("VLC_PLUGIN_PATH","\\program files\\videolan\\plugins",1);
setenv("VLC_PLUGIN_PATH","c:\\program files\\videolan\\vlc\\plugins",1);
#endif
libvlc = libvlc_new(vlc_argc, &vlc_argv[0]);
}
if(libvlc == NULL) {
#if defined(WIN32)
_putenv("VLC_PLUGIN_PATH=\\program files\\videolan\\vlc\\plugins");
#else
setenv("VLC_PLUGIN_PATH","\\program files\\videolan\\vlc\\plugins",1);
#endif
libvlc = libvlc_new(vlc_argc, &vlc_argv[0]);
if(libvlc == NULL) {
#if defined(WIN32)
_putenv("VLC_PLUGIN_PATH=c:\\program files (x86)\\videolan\\plugins");
_putenv("VLC_PLUGIN_PATH=c:\\program files (x86)\\videolan\\vlc\\plugins");
#else
setenv("VLC_PLUGIN_PATH","c:\\program files (x86)\\videolan\\plugins",1);
setenv("VLC_PLUGIN_PATH","c:\\program files (x86)\\videolan\\vlc\\plugins",1);
#endif
libvlc = libvlc_new(vlc_argc, &vlc_argv[0]);
if(libvlc == NULL) {
#if defined(WIN32)
_putenv("VLC_PLUGIN_PATH=\\program files (x86)\\videolan\\plugins");
_putenv("VLC_PLUGIN_PATH=\\program files (x86)\\videolan\\vlc\\plugins");
#else
setenv("VLC_PLUGIN_PATH","\\program files (x86)\\videolan\\plugins",1);
setenv("VLC_PLUGIN_PATH","\\program files (x86)\\videolan\\vlc\\plugins",1);
#endif
libvlc = libvlc_new(vlc_argc, &vlc_argv[0]);
}