diff --git a/mozilla/embedding/browser/activex/src/control_kicker/ReadMe.txt b/mozilla/embedding/browser/activex/src/control_kicker/ReadMe.txt new file mode 100644 index 00000000000..ed3ace6b813 --- /dev/null +++ b/mozilla/embedding/browser/activex/src/control_kicker/ReadMe.txt @@ -0,0 +1,37 @@ +======================================================================== + DYNAMIC LINK LIBRARY : control_kicker +======================================================================== + + +AppWizard has created this control_kicker DLL for you. + +This file contains a summary of what you will find in each of the files that +make up your control_kicker application. + +control_kicker.dsp + This file (the project file) contains information at the project level and + is used to build a single project or subproject. Other users can share the + project (.dsp) file, but they should export the makefiles locally. + +control_kicker.cpp + This is the main DLL source file. + +control_kicker.h + This file contains your DLL exports. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named control_kicker.pch and a precompiled types file named StdAfx.obj. + + +///////////////////////////////////////////////////////////////////////////// +Other notes: + +AppWizard uses "TODO:" to indicate parts of the source code you +should add to or customize. + + +///////////////////////////////////////////////////////////////////////////// diff --git a/mozilla/embedding/browser/activex/src/control_kicker/StdAfx.cpp b/mozilla/embedding/browser/activex/src/control_kicker/StdAfx.cpp new file mode 100644 index 00000000000..06537072f18 --- /dev/null +++ b/mozilla/embedding/browser/activex/src/control_kicker/StdAfx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes +// control_kicker.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file diff --git a/mozilla/embedding/browser/activex/src/control_kicker/StdAfx.h b/mozilla/embedding/browser/activex/src/control_kicker/StdAfx.h new file mode 100644 index 00000000000..30612c85763 --- /dev/null +++ b/mozilla/embedding/browser/activex/src/control_kicker/StdAfx.h @@ -0,0 +1,26 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#if !defined(AFX_STDAFX_H__7F2751C5_DFC7_4E43_BE16_785116B26B4A__INCLUDED_) +#define AFX_STDAFX_H__7F2751C5_DFC7_4E43_BE16_785116B26B4A__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + + +// Insert your headers here +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers + +#include +#include +#include + +// TODO: reference additional headers your program requires here + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_STDAFX_H__7F2751C5_DFC7_4E43_BE16_785116B26B4A__INCLUDED_) diff --git a/mozilla/embedding/browser/activex/src/control_kicker/control_kicker.cpp b/mozilla/embedding/browser/activex/src/control_kicker/control_kicker.cpp new file mode 100644 index 00000000000..d1e59d15ec7 --- /dev/null +++ b/mozilla/embedding/browser/activex/src/control_kicker/control_kicker.cpp @@ -0,0 +1,239 @@ +// control_kicker.cpp : Defines the entry point for the DLL application. +// + +#include "stdafx.h" + +#include "shlobj.h" + +static HMODULE ghMozCtlX = NULL; +static HMODULE ghMozCtl = NULL; + +static const _TCHAR *c_szMozCtlDll = _T("mozctl.dll"); +static const _TCHAR *c_szMozillaControlKey = _T("Software\\Mozilla\\"); +static const _TCHAR *c_szMozillaBinDirPathValue = _T("BinDirectoryPath"); +static const _TCHAR *c_szMozCtlInProcServerKey = _T("CLSID\\{1339B54C-3453-11D2-93B9-000000000000}\\InProcServer32"); + +BOOL APIENTRY DllMain( HANDLE hModule, + DWORD ul_reason_for_call, + LPVOID lpReserved + ) +{ + switch (ul_reason_for_call) + { + case DLL_PROCESS_ATTACH: + ghMozCtlX = (HMODULE) hModule; + break; + case DLL_THREAD_ATTACH: + break; + case DLL_THREAD_DETACH: + break; + case DLL_PROCESS_DETACH: + break; + } + return TRUE; +} + + +static BOOL LoadMozLibrary(BOOL bAskUserToSetPath = TRUE) +{ + if (ghMozCtl) + { + return TRUE; + } + + ghMozCtl = LoadLibrary(c_szMozCtlDll); + if (ghMozCtl) + { + return TRUE; + } + + // Try modifying the PATH environment variable + HKEY hkey = NULL; + DWORD dwDisposition = 0; + RegCreateKeyEx(HKEY_LOCAL_MACHINE, c_szMozillaControlKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, NULL); + if (hkey) + { + _TCHAR szBinDirPath[MAX_PATH + 1]; + DWORD dwBufSize = sizeof(szBinDirPath); + DWORD dwType = REG_SZ; + + ZeroMemory(szBinDirPath, dwBufSize); + RegQueryValueEx(hkey, c_szMozillaBinDirPathValue, NULL, &dwType, (LPBYTE) szBinDirPath, &dwBufSize); + + // Append the bin dir path to the PATH environment variable + int nPathLength = lstrlen(szBinDirPath); + if (bAskUserToSetPath && nPathLength == 0) + { + // TODO ask the user if they wish to set the bin dir path to something + // Show a folder picker for the user to choose the bin directory + BROWSEINFO bi; + ZeroMemory(&bi, sizeof(bi)); + bi.hwndOwner = NULL; + bi.pidlRoot = NULL; + bi.pszDisplayName = szBinDirPath; + bi.lpszTitle = _T("Pick where the Mozilla bin directory is located, e.g. (c:\\mozilla\\bin)"); + LPITEMIDLIST pItemList = SHBrowseForFolder(&bi); + if (pItemList) + { + // Get the path from the user selection + IMalloc *pShellAllocator = NULL; + SHGetMalloc(&pShellAllocator); + if (pShellAllocator) + { + char szPath[MAX_PATH + 1]; + + if (SHGetPathFromIDList(pItemList, szPath)) + { + // Chop off the end path seperator + int nPathSize = strlen(szPath); + if (nPathSize > 0) + { + if (szPath[nPathSize - 1] == '\\') + { + szPath[nPathSize - 1] = '\0'; + } + } + + // Form the file pattern +#ifdef UNICODE + MultiByteToWideChar(CP_ACP, 0, szPath, szBinDirPath, -1, sizeof(szBinDirPath) / sizeof(_TCHAR)); +#else + lstrcpy(szBinDirPath, szPath); +#endif + } + pShellAllocator->Free(pItemList); + pShellAllocator->Release(); + } + } + + // Store the new path if it was set + nPathLength = lstrlen(szBinDirPath); + if (nPathLength > 0) + { + RegSetValueEx(hkey, c_szMozillaBinDirPathValue, 0, REG_SZ, + (LPBYTE) szBinDirPath, _tcslen(szBinDirPath) * sizeof(_TCHAR)); + } + } + + RegCloseKey(hkey); + + if (nPathLength > 0) + { + _TCHAR szPath[8192]; + + ZeroMemory(szPath, sizeof(szPath)); + GetEnvironmentVariable("PATH", szPath, sizeof(szPath) / sizeof(_TCHAR)); + lstrcat(szPath, _T(";")); + lstrcat(szPath, szBinDirPath); + SetEnvironmentVariable("PATH", szPath); + + ghMozCtl = LoadLibrary(c_szMozCtlDll); + if (ghMozCtl) + { + return TRUE; + } + } + } + + return FALSE; +} + + +static BOOL FixupInProcRegistryEntry() +{ + _TCHAR szMozCtlXLongPath[MAX_PATH+1]; + ZeroMemory(szMozCtlXLongPath, sizeof(szMozCtlXLongPath)); + GetModuleFileName(ghMozCtlX, szMozCtlXLongPath, sizeof(szMozCtlXLongPath) * sizeof(_TCHAR)); + + _TCHAR szMozCtlXPath[MAX_PATH+1]; + ZeroMemory(szMozCtlXPath, sizeof(szMozCtlXPath)); + GetShortPathName(szMozCtlXLongPath, szMozCtlXPath, sizeof(szMozCtlXPath) * sizeof(_TCHAR)); + + HKEY hkey = NULL; + RegOpenKeyEx(HKEY_CLASSES_ROOT, c_szMozCtlInProcServerKey, 0, KEY_ALL_ACCESS, &hkey); + if (hkey) + { + RegSetValueEx(hkey, NULL, 0, REG_SZ, (LPBYTE) szMozCtlXPath, lstrlen(szMozCtlXPath) * sizeof(_TCHAR)); + RegCloseKey(hkey); + return TRUE; + } + + return FALSE; +} + +///////////////////////////////////////////////////////////////////////////// +// Used to determine whether the DLL can be unloaded by OLE + +typedef HRESULT (STDAPICALLTYPE *DllCanUnloadNowFn)(void); + +STDAPI DllCanUnloadNow(void) +{ + if (LoadMozLibrary()) + { + DllCanUnloadNowFn pfn = (DllCanUnloadNowFn) GetProcAddress(ghMozCtl, _T("DllCanUnloadNow")); + if (pfn) + { + return pfn(); + } + } + return S_OK; +} + +///////////////////////////////////////////////////////////////////////////// +// Returns a class factory to create an object of the requested type + +typedef HRESULT (STDAPICALLTYPE *DllGetClassObjectFn)(REFCLSID rclsid, REFIID riid, LPVOID* ppv); + +STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) +{ + if (LoadMozLibrary()) + { + DllGetClassObjectFn pfn = (DllGetClassObjectFn) GetProcAddress(ghMozCtl, _T("DllGetClassObject")); + if (pfn) + { + return pfn(rclsid, riid, ppv); + } + } + return E_FAIL; +} + +///////////////////////////////////////////////////////////////////////////// +// DllRegisterServer - Adds entries to the system registry + +typedef HRESULT (STDAPICALLTYPE *DllRegisterServerFn)(void); + +STDAPI DllRegisterServer(void) +{ + if (LoadMozLibrary()) + { + DllRegisterServerFn pfn = (DllRegisterServerFn) GetProcAddress(ghMozCtl, _T("DllRegisterServer")); + if (pfn) + { + HRESULT hr = pfn(); + if (SUCCEEDED(hr)) + { + FixupInProcRegistryEntry(); + } + return hr; + } + } + return E_FAIL; +} + +///////////////////////////////////////////////////////////////////////////// +// DllUnregisterServer - Removes entries from the system registry + +typedef HRESULT (STDAPICALLTYPE *DllUnregisterServerFn)(void); + +STDAPI DllUnregisterServer(void) +{ + if (LoadMozLibrary()) + { + DllUnregisterServerFn pfn = (DllUnregisterServerFn) GetProcAddress(ghMozCtl, _T("DllUnregisterServer")); + if (pfn) + { + return pfn(); + } + } + return E_FAIL; +} diff --git a/mozilla/embedding/browser/activex/src/control_kicker/control_kicker.dsp b/mozilla/embedding/browser/activex/src/control_kicker/control_kicker.dsp new file mode 100644 index 00000000000..fce4b43640d --- /dev/null +++ b/mozilla/embedding/browser/activex/src/control_kicker/control_kicker.dsp @@ -0,0 +1,124 @@ +# Microsoft Developer Studio Project File - Name="control_kicker" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=control_kicker - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "control_kicker.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "control_kicker.mak" CFG="control_kicker - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "control_kicker - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "control_kicker - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "control_kicker - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CONTROL_KICKER_EXPORTS" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /MT /W3 /GX- /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CONTROL_KICKER_EXPORTS" /Yu"stdafx.h" /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x1809 /d "NDEBUG" +# ADD RSC /l 0x1809 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /dll /machine:I386 /out:"Release/mozctlx.dll" + +!ELSEIF "$(CFG)" == "control_kicker - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CONTROL_KICKER_EXPORTS" /Yu"stdafx.h" /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX- /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /Yu"stdafx.h" /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x1809 /d "_DEBUG" +# ADD RSC /l 0x1809 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"Debug/mozctlx.dll" /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "control_kicker - Win32 Release" +# Name "control_kicker - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\control_kicker.cpp +# End Source File +# Begin Source File + +SOURCE=.\mozctlx.def +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.cpp +# ADD CPP /Yc"stdafx.h" +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\StdAfx.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# Begin Source File + +SOURCE=.\ReadMe.txt +# End Source File +# End Target +# End Project diff --git a/mozilla/embedding/browser/activex/src/control_kicker/control_kicker.h b/mozilla/embedding/browser/activex/src/control_kicker/control_kicker.h new file mode 100644 index 00000000000..cabad3129a8 --- /dev/null +++ b/mozilla/embedding/browser/activex/src/control_kicker/control_kicker.h @@ -0,0 +1,35 @@ + +#ifde +///////////////////////////////////////////////////////////////////////////// +// Used to determine whether the DLL can be unloaded by OLE + +STDAPI DllCanUnloadNow(void) +{ + return (_Module.GetLockCount()==0) ? S_OK : S_FALSE; +} + +///////////////////////////////////////////////////////////////////////////// +// Returns a class factory to create an object of the requested type + +STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) +{ + return _Module.GetClassObject(rclsid, riid, ppv); +} + +///////////////////////////////////////////////////////////////////////////// +// DllRegisterServer - Adds entries to the system registry + +STDAPI DllRegisterServer(void) +{ + // registers object, typelib and all interfaces in typelib + return _Module.RegisterServer(TRUE); +} + +///////////////////////////////////////////////////////////////////////////// +// DllUnregisterServer - Removes entries from the system registry + +STDAPI DllUnregisterServer(void) +{ + _Module.UnregisterServer(); + return S_OK; +} diff --git a/mozilla/embedding/browser/activex/src/control_kicker/mozctlx.def b/mozilla/embedding/browser/activex/src/control_kicker/mozctlx.def new file mode 100644 index 00000000000..ff3d02029e4 --- /dev/null +++ b/mozilla/embedding/browser/activex/src/control_kicker/mozctlx.def @@ -0,0 +1,10 @@ +; mozctlx.def : Declares the module parameters. + +LIBRARY "mozctlx.dll" +EXPORTS + ; ActiveX exports + DllCanUnloadNow @100 PRIVATE + DllGetClassObject @101 PRIVATE + DllRegisterServer @102 PRIVATE + DllUnregisterServer @103 PRIVATE +