forked from openlp/openlp
Further detection efforts
This commit is contained in:
parent
91d53b7adc
commit
7080e910c2
@ -27,6 +27,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <io.h>
|
||||||
|
#include <direct.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@ -88,7 +90,12 @@ DllExport BOOL CheckInstalled()
|
|||||||
char cmdLine[MAX_PATH * 2];
|
char cmdLine[MAX_PATH * 2];
|
||||||
|
|
||||||
DEBUG("CheckInstalled\n");
|
DEBUG("CheckInstalled\n");
|
||||||
return GetPPTViewerPath(cmdLine, sizeof(cmdLine));
|
BOOL found = GetPPTViewerPath(cmdLine, sizeof(cmdLine));
|
||||||
|
if(found)
|
||||||
|
{
|
||||||
|
DEBUG("Exe: %s\n", cmdLine);
|
||||||
|
}
|
||||||
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open the PointPoint, count the slides and take a snapshot of each slide
|
// Open the PointPoint, count the slides and take a snapshot of each slide
|
||||||
@ -160,7 +167,7 @@ DllExport int OpenPPT(char *filename, HWND hParentWnd, RECT rect,
|
|||||||
pptView[id].rect.bottom = rect.bottom;
|
pptView[id].rect.bottom = rect.bottom;
|
||||||
pptView[id].rect.right = rect.right;
|
pptView[id].rect.right = rect.right;
|
||||||
}
|
}
|
||||||
strcat_s(cmdLine, MAX_PATH * 2, "/F /S \"");
|
strcat_s(cmdLine, MAX_PATH * 2, " /F /S \"");
|
||||||
strcat_s(cmdLine, MAX_PATH * 2, filename);
|
strcat_s(cmdLine, MAX_PATH * 2, filename);
|
||||||
strcat_s(cmdLine, MAX_PATH * 2, "\"");
|
strcat_s(cmdLine, MAX_PATH * 2, "\"");
|
||||||
memset(&si, 0, sizeof(si));
|
memset(&si, 0, sizeof(si));
|
||||||
@ -189,7 +196,7 @@ DllExport int OpenPPT(char *filename, HWND hParentWnd, RECT rect,
|
|||||||
Sleep(10);
|
Sleep(10);
|
||||||
if (!CreateProcess(NULL, cmdLine, NULL, NULL, FALSE, 0, 0, NULL, &si, &pi))
|
if (!CreateProcess(NULL, cmdLine, NULL, NULL, FALSE, 0, 0, NULL, &si, &pi))
|
||||||
{
|
{
|
||||||
DEBUG("OpenPPT: CreateProcess failed\n");
|
DEBUG("OpenPPT: CreateProcess failed: %s\n", cmdLine);
|
||||||
ClosePPT(id);
|
ClosePPT(id);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -344,24 +351,79 @@ BOOL SavePPTInfo(int id)
|
|||||||
|
|
||||||
// Get the path of the PowerPoint viewer from the registry
|
// Get the path of the PowerPoint viewer from the registry
|
||||||
BOOL GetPPTViewerPath(char *pptViewerPath, int stringSize)
|
BOOL GetPPTViewerPath(char *pptViewerPath, int stringSize)
|
||||||
|
{
|
||||||
|
char cwd[MAX_PATH];
|
||||||
|
|
||||||
|
DEBUG("GetPPTViewerPath: start\n");
|
||||||
|
if(GetPPTViewerPathFromReg(pptViewerPath, stringSize))
|
||||||
|
{
|
||||||
|
if(_access(pptViewerPath, 0) != -1)
|
||||||
|
{
|
||||||
|
DEBUG("GetPPTViewerPath: exit registry\n");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// This is where it gets ugly. PPT2007 it seems no longer stores its
|
||||||
|
// location in the registry. So we have to use the defaults which will
|
||||||
|
// upset those who like to put things somewhere else
|
||||||
|
|
||||||
|
// Viewer 2007 in 64bit Windows:
|
||||||
|
if(_access("C:\\Program Files (x86)\\Microsoft Office\\Office12\\PPTVIEW.EXE",
|
||||||
|
0) != -1)
|
||||||
|
{
|
||||||
|
strcpy_s(
|
||||||
|
"C:\\Program Files (x86)\\Microsoft Office\\Office12\\PPTVIEW.EXE",
|
||||||
|
stringSize, pptViewerPath);
|
||||||
|
DEBUG("GetPPTViewerPath: exit 64bit 2007\n");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
// Viewer 2007 in 32bit Windows:
|
||||||
|
if(_access("C:\\Program Files\\Microsoft Office\\Office12\\PPTVIEW.EXE", 0)
|
||||||
|
!= -1)
|
||||||
|
{
|
||||||
|
strcpy_s("C:\\Program Files\\Microsoft Office\\Office12\\PPTVIEW.EXE",
|
||||||
|
stringSize, pptViewerPath);
|
||||||
|
DEBUG("GetPPTViewerPath: exit 32bit 2007\n");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
// Give them the opportunity to place it in the same folder as the app
|
||||||
|
_getcwd(cwd, MAX_PATH);
|
||||||
|
strcat_s(cwd, MAX_PATH, "\\PPTVIEW.EXE");
|
||||||
|
if(_access(cwd, 0) != -1)
|
||||||
|
{
|
||||||
|
strcpy_s(pptViewerPath, stringSize, cwd);
|
||||||
|
DEBUG("GetPPTViewerPath: exit local\n");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
DEBUG("GetPPTViewerPath: exit fail\n");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
BOOL GetPPTViewerPathFromReg(char *pptViewerPath, int stringSize)
|
||||||
{
|
{
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
DWORD dwType, dwSize;
|
DWORD dwType, dwSize;
|
||||||
LRESULT lResult;
|
LRESULT lResult;
|
||||||
|
|
||||||
DEBUG("GetPPTViewerPath: start\n");
|
// The following registry settings are for, respectively, (I think)
|
||||||
if (RegOpenKeyEx(HKEY_CLASSES_ROOT,
|
// PPT Viewer 2007 (older versions. Latest not in registry) & PPT Viewer 2010
|
||||||
|
// PPT Viewer 2003 (recent versions)
|
||||||
|
// PPT Viewer 2003 (older versions)
|
||||||
|
// PPT Viewer 97
|
||||||
|
if ((RegOpenKeyEx(HKEY_CLASSES_ROOT,
|
||||||
"PowerPointViewer.Show.12\\shell\\Show\\command", 0, KEY_READ, &hKey)
|
"PowerPointViewer.Show.12\\shell\\Show\\command", 0, KEY_READ, &hKey)
|
||||||
!= ERROR_SUCCESS)
|
!= ERROR_SUCCESS)
|
||||||
if(RegOpenKeyEx(HKEY_CLASSES_ROOT,
|
&& (RegOpenKeyEx(HKEY_CLASSES_ROOT,
|
||||||
"Applications\\PPTVIEW.EXE\\shell\\open\\command", 0, KEY_READ, &hKey)
|
"PowerPointViewer.Show.11\\shell\\Show\\command", 0, KEY_READ, &hKey)
|
||||||
!= ERROR_SUCCESS)
|
!= ERROR_SUCCESS)
|
||||||
if (RegOpenKeyEx(HKEY_CLASSES_ROOT,
|
&& (RegOpenKeyEx(HKEY_CLASSES_ROOT,
|
||||||
"Applications\\PPTVIEW.EXE\\shell\\Show\\command", 0, KEY_READ, &hKey)
|
"Applications\\PPTVIEW.EXE\\shell\\open\\command", 0, KEY_READ, &hKey)
|
||||||
!= ERROR_SUCCESS)
|
!= ERROR_SUCCESS)
|
||||||
{
|
&& (RegOpenKeyEx(HKEY_CLASSES_ROOT,
|
||||||
return FALSE;
|
"Applications\\PPTVIEW.EXE\\shell\\Show\\command", 0, KEY_READ, &hKey)
|
||||||
}
|
!= ERROR_SUCCESS))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
dwType = REG_SZ;
|
dwType = REG_SZ;
|
||||||
dwSize = (DWORD)stringSize;
|
dwSize = (DWORD)stringSize;
|
||||||
lResult = RegQueryValueEx(hKey, NULL, NULL, &dwType, (LPBYTE)pptViewerPath,
|
lResult = RegQueryValueEx(hKey, NULL, NULL, &dwType, (LPBYTE)pptViewerPath,
|
||||||
@ -373,7 +435,6 @@ BOOL GetPPTViewerPath(char *pptViewerPath, int stringSize)
|
|||||||
}
|
}
|
||||||
// remove "%1" from end of key value
|
// remove "%1" from end of key value
|
||||||
pptViewerPath[strlen(pptViewerPath) - 4] = '\0';
|
pptViewerPath[strlen(pptViewerPath) - 4] = '\0';
|
||||||
DEBUG("GetPPTViewerPath: exit ok\n");
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Binary file not shown.
@ -49,6 +49,7 @@ LRESULT CALLBACK CbtProc(int nCode, WPARAM wParam, LPARAM lParam);
|
|||||||
LRESULT CALLBACK CwpProc(int nCode, WPARAM wParam, LPARAM lParam);
|
LRESULT CALLBACK CwpProc(int nCode, WPARAM wParam, LPARAM lParam);
|
||||||
LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam);
|
LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam);
|
||||||
BOOL GetPPTViewerPath(char *pptViewerPath, int stringSize);
|
BOOL GetPPTViewerPath(char *pptViewerPath, int stringSize);
|
||||||
|
BOOL GetPPTViewerPathFromReg(char *pptViewerPath, int stringSize);
|
||||||
HBITMAP CaptureWindow(HWND hWnd);
|
HBITMAP CaptureWindow(HWND hWnd);
|
||||||
VOID SaveBitmap(CHAR* filename, HBITMAP hBmp) ;
|
VOID SaveBitmap(CHAR* filename, HBITMAP hBmp) ;
|
||||||
VOID CaptureAndSaveWindow(HWND hWnd, CHAR* filename);
|
VOID CaptureAndSaveWindow(HWND hWnd, CHAR* filename);
|
||||||
|
Loading…
Reference in New Issue
Block a user