-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #373 from lwahonen/master
Small COM fixes
- Loading branch information
Showing
2 changed files
with
18 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,7 +35,7 @@ | |
// TODO: Auto-generated Javadoc | ||
/** | ||
* Helper class to provide basic COM support. | ||
* | ||
* | ||
* @author Tobias Wolf, [email protected] | ||
*/ | ||
public class COMBindingBaseObject extends COMInvoker { | ||
|
@@ -72,8 +72,9 @@ public COMBindingBaseObject(CLSID clsid, boolean useActiveInstance) { | |
public COMBindingBaseObject(CLSID clsid, boolean useActiveInstance, | ||
int dwClsContext) { | ||
// Initialize COM for this thread... | ||
HRESULT hr = Ole32.INSTANCE.CoInitialize(null); | ||
|
||
HRESULT hr = Ole32.INSTANCE.CoInitializeEx(null, Ole32.COINIT_APARTMENTTHREADED); | ||
if (hr.intValue() == 1) // Already initialized, no problem | ||
hr = new HRESULT(0); | ||
if (COMUtils.FAILED(hr)) { | ||
Ole32.INSTANCE.CoUninitialize(); | ||
throw new COMException("CoInitialize() failed!"); | ||
|
@@ -106,7 +107,9 @@ public COMBindingBaseObject(CLSID clsid, boolean useActiveInstance, | |
public COMBindingBaseObject(String progId, boolean useActiveInstance, | ||
int dwClsContext) throws COMException { | ||
// Initialize COM for this thread... | ||
HRESULT hr = Ole32.INSTANCE.CoInitialize(null); | ||
HRESULT hr = Ole32.INSTANCE.CoInitializeEx(null, Ole32.COINIT_APARTMENTTHREADED); | ||
if (hr.intValue() == 1) // Already initialized, no problem | ||
hr = new HRESULT(0); | ||
|
||
if (COMUtils.FAILED(hr)) { | ||
this.release(); | ||
|
@@ -154,7 +157,7 @@ public COMBindingBaseObject(String progId, boolean useActiveInstance) | |
|
||
/** | ||
* Gets the i dispatch. | ||
* | ||
* | ||
* @return the i dispatch | ||
*/ | ||
public IDispatch getIDispatch() { | ||
|
@@ -163,7 +166,7 @@ public IDispatch getIDispatch() { | |
|
||
/** | ||
* Gets the i dispatch pointer. | ||
* | ||
* | ||
* @return the i dispatch pointer | ||
*/ | ||
public PointerByReference getIDispatchPointer() { | ||
|
@@ -172,7 +175,7 @@ public PointerByReference getIDispatchPointer() { | |
|
||
/** | ||
* Gets the i unknown. | ||
* | ||
* | ||
* @return the i unknown | ||
*/ | ||
public IUnknown getIUnknown() { | ||
|
@@ -181,7 +184,7 @@ public IUnknown getIUnknown() { | |
|
||
/** | ||
* Gets the i unknown pointer. | ||
* | ||
* | ||
* @return the i unknown pointer | ||
*/ | ||
public PointerByReference getIUnknownPointer() { | ||
|
@@ -270,7 +273,7 @@ protected HRESULT oleMethod(int nType, VARIANT.ByReference pvResult, | |
|
||
/** | ||
* Ole method. | ||
* | ||
* | ||
* @param nType | ||
* the n type | ||
* @param pvResult | ||
|
@@ -301,7 +304,7 @@ protected HRESULT oleMethod(int nType, VARIANT.ByReference pvResult, | |
|
||
/** | ||
* Ole method. | ||
* | ||
* | ||
* @param nType | ||
* the n type | ||
* @param pvResult | ||
|
@@ -328,7 +331,7 @@ protected HRESULT oleMethod(int nType, VARIANT.ByReference pvResult, | |
|
||
/** | ||
* Check failed. | ||
* | ||
* | ||
* @param hr | ||
* the hr | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters