Skip to content

Small COM fixes #373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 24, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
// TODO: Auto-generated Javadoc
/**
* Helper class to provide basic COM support.
*
*
* @author Tobias Wolf, wolf.tobias@gmx.net
*/
public class COMBindingBaseObject extends COMInvoker {
Expand Down Expand Up @@ -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!");
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -154,7 +157,7 @@ public COMBindingBaseObject(String progId, boolean useActiveInstance)

/**
* Gets the i dispatch.
*
*
* @return the i dispatch
*/
public IDispatch getIDispatch() {
Expand All @@ -163,7 +166,7 @@ public IDispatch getIDispatch() {

/**
* Gets the i dispatch pointer.
*
*
* @return the i dispatch pointer
*/
public PointerByReference getIDispatchPointer() {
Expand All @@ -172,7 +175,7 @@ public PointerByReference getIDispatchPointer() {

/**
* Gets the i unknown.
*
*
* @return the i unknown
*/
public IUnknown getIUnknown() {
Expand All @@ -181,7 +184,7 @@ public IUnknown getIUnknown() {

/**
* Gets the i unknown pointer.
*
*
* @return the i unknown pointer
*/
public PointerByReference getIUnknownPointer() {
Expand Down Expand Up @@ -270,7 +273,7 @@ protected HRESULT oleMethod(int nType, VARIANT.ByReference pvResult,

/**
* Ole method.
*
*
* @param nType
* the n type
* @param pvResult
Expand Down Expand Up @@ -301,7 +304,7 @@ protected HRESULT oleMethod(int nType, VARIANT.ByReference pvResult,

/**
* Ole method.
*
*
* @param nType
* the n type
* @param pvResult
Expand All @@ -328,7 +331,7 @@ protected HRESULT oleMethod(int nType, VARIANT.ByReference pvResult,

/**
* Check failed.
*
*
* @param hr
* the hr
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ public static ArrayList<COMInfo> getAllCOMInfoOnSystem() {
try {
// open root key
phkResult = Advapi32Util.registryGetKey(WinReg.HKEY_CLASSES_ROOT,
"CLSID", WinNT.KEY_ALL_ACCESS);
"CLSID", WinNT.KEY_READ);
// open subkey
InfoKey infoKey = Advapi32Util.registryQueryInfoKey(
phkResult.getValue(), WinNT.KEY_ALL_ACCESS);
phkResult.getValue(), WinNT.KEY_READ);

for (int i = 0; i < infoKey.lpcSubKeys.getValue(); i++) {
EnumKey enumKey = Advapi32Util.registryRegEnumKey(
Expand All @@ -141,9 +141,9 @@ public static ArrayList<COMInfo> getAllCOMInfoOnSystem() {
COMInfo comInfo = new COMInfo(subKey);

phkResult2 = Advapi32Util.registryGetKey(phkResult.getValue(),
subKey, WinNT.KEY_ALL_ACCESS);
subKey, WinNT.KEY_READ);
InfoKey infoKey2 = Advapi32Util.registryQueryInfoKey(
phkResult2.getValue(), WinNT.KEY_ALL_ACCESS);
phkResult2.getValue(), WinNT.KEY_READ);

for (int y = 0; y < infoKey2.lpcSubKeys.getValue(); y++) {
EnumKey enumKey2 = Advapi32Util.registryRegEnumKey(
Expand Down