>From 4403b1c81e7f3a2c04549c93344049da55a3caa5 Mon Sep 17 00:00:00 2001
From: Sergey Radionov <RSATom@gmail.com>
Date: Fri, 18 Nov 2011 09:10:49 +0700
Subject: [PATCH 2/2] ActiveX: Changed files to be compilable by VC.

---
 activex/connectioncontainer.cpp |    2 ++
 activex/main.cpp                |   29 +++++++++++++++--------------
 activex/persiststreaminit.cpp   |    4 +++-
 activex/plugin.cpp              |    4 ++++
 activex/position.h              |    4 ++++
 5 files changed, 28 insertions(+), 15 deletions(-)

diff --git a/activex/connectioncontainer.cpp b/activex/connectioncontainer.cpp
index 7d3800c..77cec70 100644
--- a/activex/connectioncontainer.cpp
+++ b/activex/connectioncontainer.cpp
@@ -33,6 +33,7 @@
 
 using namespace std;
 
+#ifndef _MSC_VER
 ////////////////////////////////////////////////////////////////////////////////////////////////
 DEFINE_GUID(IID_IGlobalInterfaceTable,     0x00000146, 0x0000, 0x0000, 0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46);
 DEFINE_GUID(CLSID_StdGlobalInterfaceTable, 0x00000323, 0x0000, 0x0000, 0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46);
@@ -40,6 +41,7 @@ DEFINE_GUID(CLSID_StdGlobalInterfaceTable, 0x00000323, 0x0000, 0x0000, 0xc0,0x00
 const GUID  IID_IGlobalInterfaceTable = { 0x00000146, 0, 0, {0xc0, 0, 0, 0, 0, 0, 0, 0x46} };
 const CLSID CLSID_StdGlobalInterfaceTable = { 0x00000323, 0, 0, {0xc0, 0, 0, 0, 0, 0, 0, 0x46} };
 ////////////////////////////////////////////////////////////////////////////////////////////////
+#endif
 
 /* this function object is used to return the value from a map pair */
 struct VLCEnumConnectionsDereference
diff --git a/activex/main.cpp b/activex/main.cpp
index c57c813..8e481c5 100644
--- a/activex/main.cpp
+++ b/activex/main.cpp
@@ -31,15 +31,13 @@
 
 #include <tchar.h>
 
+#ifdef __MINGW32__
 #include <_mingw.h>
+#endif
 
-#ifdef __MINGW64_VERSION_MAJOR
-
-#include <guiddef.h>
 #include <objsafe.h>
 
-#else /* ! __MINGW64_VERSION_MAJOR */
-
+#if defined(__MINGW32_MAJOR_VERSION) && !defined(__MINGW64_VERSION_MAJOR)
 /*
 ** Widl generated code requires guiddef.h,
 ** which is not available under MinGW32
@@ -54,13 +52,11 @@
 /* CATID_InternetAware is declared as extern but not present in library */
 DEFINE_GUID(CATID_InternetAware, \
     0x0DE86A58, 0x2BAA, 0x11CF, 0xA2, 0x29, 0x00,0xAA,0x00,0x3D,0x73,0x52);
-static DEFINE_GUID(CATID_SafeForInitializing, \
-	0x7DD95802, 0x9882, 0x11CF, 0x9F, 0xA9, 0x00,0xAA,0x00,0x6C,0x42,0xC4);
-static DEFINE_GUID(CATID_SafeForScripting, \
-	0x7DD95801, 0x9882, 0x11CF, 0x9F, 0xA9, 0x00,0xAA,0x00,0x6C,0x42,0xC4);
-
-#endif /* __MINGW64_VERSION_MAJOR */
-
+DEFINE_GUID(CATID_SafeForInitializing, \
+    0x7DD95802, 0x9882, 0x11CF, 0x9F, 0xA9, 0x00,0xAA,0x00,0x6C,0x42,0xC4);
+DEFINE_GUID(CATID_SafeForScripting, \
+    0x7DD95801, 0x9882, 0x11CF, 0x9F, 0xA9, 0x00,0xAA,0x00,0x6C,0x42,0xC4);
+#endif
 
 using namespace std;
 
@@ -71,7 +67,11 @@ using namespace std;
 #define THREADING_MODEL "Apartment"
 #define MISC_STATUS     "131473"
 
+#ifdef _MSC_VER
+#define PROGID_STR "VideoLAN.VLCPlugin"
+#else
 #define PROGID_STR COMPANY_STR"."PROGRAM_STR
+#endif
 
 #define GUID_STRLEN 39
 
@@ -253,12 +253,13 @@ static HRESULT RegisterClassID(HKEY hParent, REFCLSID rclsid, unsigned int versi
 
         // ToolboxBitmap32 key value
         {
-            TCHAR iconPath[pathLen+3];
+            std::vector<TCHAR> iconPathBuf(pathLen+3, 0);
+            TCHAR* iconPath = &iconPathBuf[0];
             memcpy(iconPath, path, sizeof(TCHAR)*pathLen);
             _tcscpy(iconPath+pathLen, TEXT(",1"));
             keyClose(keySetDef(keyCreate(hClassKey,
                 TEXT("ToolboxBitmap32")),
-                iconPath, sizeof(iconPath)));
+                iconPath, sizeof(TCHAR)*(_tcslen(iconPath)+1)));
         }
 
 #ifdef BUILD_LOCALSERVER
diff --git a/activex/persiststreaminit.cpp b/activex/persiststreaminit.cpp
index 2ec4adb..fe302a1 100644
--- a/activex/persiststreaminit.cpp
+++ b/activex/persiststreaminit.cpp
@@ -25,6 +25,7 @@
 
 #include "utils.h"
 #include <map>
+#include <vector>
 
 #include <malloc.h>
 #include <wchar.h>
@@ -417,7 +418,8 @@ private:
         if( 0 == len )
             return E_INVALIDARG;
 
-        WCHAR propName[len + 1];
+        vector<WCHAR> propNameBuf(len + 1, 0);
+        WCHAR* propName = &propNameBuf[0];
 
         result = pStm->Read(propName, len*sizeof(WCHAR), NULL);
         if( FAILED(result) )
diff --git a/activex/plugin.cpp b/activex/plugin.cpp
index 2d5d1c2..0a93089 100644
--- a/activex/plugin.cpp
+++ b/activex/plugin.cpp
@@ -50,6 +50,10 @@
 #include <wininet.h>
 #include <assert.h>
 
+#ifdef _MSC_VER
+#include "../vc_config.h"
+#endif //_MSC_VER
+
 using namespace std;
 
 ////////////////////////////////////////////////////////////////////////
diff --git a/activex/position.h b/activex/position.h
index ec1c7f8..8d179df 100644
--- a/activex/position.h
+++ b/activex/position.h
@@ -22,6 +22,10 @@
 #ifndef POSITION_H
 #define POSITION_H
 
+#ifdef _MSC_VER
+#include "../vc_config.h"
+#endif //_MSC_VER
+
 struct posidx_s { const char *n; size_t i; };
 static const posidx_s posidx[] = {
     { "center",        0 },
-- 
1.7.7.1.msysgit.0

