[commit] r1775 - in trunk/SDK: BON/Common Java/native/JavaCompRunner
GMESRC Repository Notifications
gme-commit at list.isis.vanderbilt.edu
Thu Jan 5 09:26:52 CST 2012
Author: ksmyth
Date: Thu Jan 5 09:26:51 2012
New Revision: 1775
Log:
Fix JavaCompRunner compile; it has its own ComponentDll.{h,cpp} since it operates differently
Modified:
trunk/SDK/BON/Common/ComponentObj.h
trunk/SDK/Java/native/JavaCompRunner/ComponentDll.cpp
trunk/SDK/Java/native/JavaCompRunner/ComponentDll.h
Modified: trunk/SDK/BON/Common/ComponentObj.h
==============================================================================
--- trunk/SDK/BON/Common/ComponentObj.h Wed Jan 4 17:54:50 2012 (r1774)
+++ trunk/SDK/BON/Common/ComponentObj.h Thu Jan 5 09:26:51 2012 (r1775)
@@ -8,6 +8,8 @@
#include "Core.h"
#include "Mga.h"
+#include "ComponentConfig.h"
+
#if defined(BUILDER_OBJECT_NETWORK)
#else
// BY PAKA BEGIN
Modified: trunk/SDK/Java/native/JavaCompRunner/ComponentDll.cpp
==============================================================================
--- trunk/SDK/Java/native/JavaCompRunner/ComponentDll.cpp Wed Jan 4 17:54:50 2012 (r1774)
+++ trunk/SDK/Java/native/JavaCompRunner/ComponentDll.cpp Thu Jan 5 09:26:51 2012 (r1775)
@@ -9,6 +9,10 @@
#include "ComponentConfig.h"
#include "MgaUtil.h"
+extern bool const g_REGISTER_SYSTEMWIDE;
+extern const char* g_COMPONENT_NAME;
+
+
#define COMRETURN(hr) { HRESULT res; if((res = (hr)) != S_OK) return res; }
#define VERIFYTHROW(FUNC) \
do { \
@@ -89,7 +93,7 @@
/////////////////////////////////////////////////////////////////////////////
// CComponentApp construction
-CComponentApp::CComponentApp() : CWinApp(COMPONENT_NAME)
+CComponentApp::CComponentApp() : CWinApp(g_COMPONENT_NAME)
{
}
@@ -231,16 +235,14 @@
// or from the resources. But the resource ID of the
// TYPELIB must be 1 !!!
/*
- if( !AfxOleRegisterTypeLib(AfxGetInstanceHandle(),
- LIBID_MgaComponentLib, NULL) )
+ if( !AfxOleRegisterTypeLib(AfxGetInstanceHandle(), LIBID_MgaComponentLib, NULL) )
return E_FAIL;
*/
CComponentReg reg;
-#ifdef REGISTER_SYSTEMWIDE
- COMRETURN( reg.RegisterParadigms(REGACCESS_SYSTEM));
-#else
- COMRETURN( reg.RegisterParadigms());
-#endif
+ if (g_REGISTER_SYSTEMWIDE)
+ COMRETURN(reg.RegisterParadigms(REGACCESS_SYSTEM))
+ else
+ COMRETURN(reg.RegisterParadigms())
return S_OK;
@@ -258,11 +260,10 @@
return SELFREG_E_CLASS;
CComponentReg reg;
-#ifdef REGISTER_SYSTEMWIDE
- COMRETURN( reg.UnregisterParadigms(REGACCESS_SYSTEM));
-#else
- COMRETURN( reg.UnregisterParadigms());
-#endif
+ if (g_REGISTER_SYSTEMWIDE)
+ COMRETURN(reg.UnregisterParadigms(REGACCESS_SYSTEM))
+ else
+ COMRETURN(reg.UnregisterParadigms())
return S_OK;
}
Modified: trunk/SDK/Java/native/JavaCompRunner/ComponentDll.h
==============================================================================
--- trunk/SDK/Java/native/JavaCompRunner/ComponentDll.h Wed Jan 4 17:54:50 2012 (r1774)
+++ trunk/SDK/Java/native/JavaCompRunner/ComponentDll.h Thu Jan 5 09:26:51 2012 (r1775)
@@ -1,12 +1,7 @@
// ComponentDll.h : main header file for the Component DLL
//
-#if !defined(AFX_COMPONENTAPP_H__DC43D02A_061D_11D2_BBB3_0040051F7117__INCLUDED_)
-#define AFX_COMPONENTAPP_H__DC43D02A_061D_11D2_BBB3_0040051F7117__INCLUDED_
-
-#if _MSC_VER >= 1000
#pragma once
-#endif // _MSC_VER >= 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
@@ -14,6 +9,7 @@
#include "resource.h" // main symbols
#include <vector>
+#include "MgaUtil.h"
typedef jint (JNICALL *P_JNI_CreateJavaVM) (JavaVM **pvm, void** penv, void *args);
typedef jint (JNICALL *P_JNI_GetCreatedJavaVMs) (JavaVM **vmBuf,jsize bufLen, jsize *nVMs);
@@ -57,4 +53,126 @@
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
-#endif // !defined(AFX_COMONENTAPP_H__DC43D02A_061D_11D2_BBB3_0040051F7117__INCLUDED_)
+
+
+class CUACUtils
+{
+public:
+
+ // Vista-dependent icon constants (copied from Commctrl.h)
+#ifndef BCM_FIRST
+ static const DWORD BCM_FIRST = 0x1600;
+#endif
+#ifndef BCM_SETSHIELD
+ static const DWORD BCM_SETSHIELD = (BCM_FIRST + 0x000C);
+#endif
+
+ static bool isVistaOrLater()
+ {
+ OSVERSIONINFO osvi;
+
+ ::ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
+ osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+
+ GetVersionEx(&osvi);
+
+ return (osvi.dwMajorVersion >= 6);
+ }
+
+ static bool isElevated()
+ {
+ if ( !isVistaOrLater() ) {
+ return true;
+ }
+
+ HANDLE hToken = NULL;
+
+ if ( !::OpenProcessToken(
+ ::GetCurrentProcess(),
+ TOKEN_QUERY,
+ &hToken ) )
+ {
+ return false;
+ }
+
+ DWORD dwReturnLength = 0;
+ TOKEN_ELEVATION te;
+ ::ZeroMemory(&te, sizeof(te));
+
+ if ( ::GetTokenInformation(
+ hToken,
+ TokenElevation,
+ &te,
+ sizeof(te),
+ &dwReturnLength ) )
+ {
+ ASSERT( dwReturnLength == sizeof( te ) );
+ return (te.TokenIsElevated != 0);
+ }
+
+ ::CloseHandle( hToken );
+
+ return false;
+ }
+
+ template <typename T>
+ static HRESULT CreateElevatedInstance(LPCOLESTR progId,
+ T** object, HWND window = 0)
+ {
+ CLSID clsId;
+ HRESULT hr = ::CLSIDFromProgID(progId, &clsId);
+ if (FAILED(hr)) {
+ return hr;
+ }
+
+ return CreateElevatedInstance(clsId, object, window);
+ }
+
+ template <typename T>
+ static HRESULT CreateElevatedInstance(REFCLSID classId,
+ T** object, HWND window = 0)
+ {
+ BIND_OPTS3 bindOptions;
+ gettokeninformation
+ ::ZeroMemory(&bindOptions, sizeof (BIND_OPTS3));
+ bindOptions.cbStruct = sizeof (BIND_OPTS3);
+ bindOptions.hwnd = window;
+ bindOptions.dwClassContext = CLSCTX_LOCAL_SERVER;
+
+ WCHAR wszMonikerName[300];
+ WCHAR wszCLSID[50];
+
+ #define cntof(a) (sizeof(a)/sizeof(a[0]))
+
+ ::StringFromGUID2(classId, wszCLSID,
+ cntof(wszCLSID));
+
+ HRESULT hr = ::StringCchPrintfW(wszMonikerName, cntof(wszMonikerName), L"Elevation:Administrator!new:%s", wszCLSID);
+
+ if (FAILED(hr))
+ {
+ return hr;
+ }
+
+ return ::CoGetObject(wszMonikerName,
+ &bindOptions,
+ __uuidof(T),
+ reinterpret_cast<void**>(object));
+ }
+
+ static void SetShieldIcon(const CButton& button, bool on=true)
+ {
+ button.SendMessage(BCM_SETSHIELD, 0, on ? TRUE : FALSE);
+ }
+};
+
+
+class CComponentReg
+{
+public:
+ CComponentReg();
+
+ CStringList paradigms;
+ HRESULT RegisterParadigms(regaccessmode_enum loc = REGACCESS_USER);
+ HRESULT UnregisterParadigms(regaccessmode_enum loc = REGACCESS_USER);
+};
More information about the gme-commit
mailing list