0

I have an SDK that I should use. This SDK does not document the concrete dll files to be used. The C header files contain a class ids instead. There are also interface and class declarations. These may be used as parameters for exported functions and also as return values.

Example declaration:

const CLSID CLSID_Core2 = {0x1111111D,0x111D,0x99bc,{0x99,0x99,0x99,0x99,0x99,0x99,0xff,0xaa}};

From the C program it is used like this:

CComPtr<ICatalog> tprogrammers;

hr = m_Core.CoCreateInstance(CLSID_Core2);
hr = m_Core->get_Programmers(&tprogrammers);

The CComPtr and ICatalog classes are defined elsewhere. CComPtr is built into windows ( https://msdn.microsoft.com/hu-hu/library/ezzw7k98.aspx ) but ICatalog is defined in a header file that is part of the SDK. The SDK contains lots of header files with interfaces and class ids, but it does not contain any implementation (C or CPP files).

Is there a chance that I can use these header files and use the installed SDK from Python?

2
  • 1
    I'm not super familiar with python, but I think you'll have to use the comtypes package: pythonhosted.org/comtypes (PS: CComPtr is not build into Windows, it's a helper class provided with Visual Studio) Commented Aug 17, 2017 at 15:11
  • The comtypes package seems to be the best solution. Please post it as an answer and I'm going to accept it. Commented Aug 25, 2017 at 8:55

2 Answers 2

1

You will have to use the comtypes package: http://pythonhosted.org/comtypes/ that supports IUnkwown* (or "early-binding") interfaces, contrary to pywin32 that only supports IDispatch* (or "late-binding") interfaces.

PS: CComPtr is not build into Windows, it's a helper class provided with Visual Studio VC++ files.

Sign up to request clarification or add additional context in comments.

Comments

0

There is no need to use the CLSID to create an object. Just use the human readable ProgID to create the object.

AFAIK Phython uses late binding (IDispatch interface), so the interface definitions are not needed here.

3 Comments

Not every COM class has a ProgId. Not every COM class is accessible by IDispatch (in fact many are not).
You are right. But AFAIK using Python it must have one and must use late binding. That what I know, may be I am wrong. stackoverflow.com/questions/1065844/…
comtypes allows non IDispatch interfaces, contrary to pywin32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.