Automation Python Client(32bit) and more
I have written a python script to use our COM Component in Python. I learned basic Python syntax for our client. I have used Python 2.7.10(32bit) version on Windows 8.1(64bit). I have added the extension comtypes to Python installation which supports Python 32 bit. That’s why I had to create our 32bit Automation server component. This extension allows us to support COM components. I have tested the Python Script and working good. 🙂 Please find the attached script file.
It took 2 days to work around this and for Java script client(did not get success). I have also tried C client. It’s very good. I feel, it actually gives us a idea about how CPP’s class must be written in C(header file for C client is highly noteworthy) and also gives clear idea about virtual function table, its actual use via lpvtbl pointer.
As you said, C# does not use our IDispatch but directly calls those two methods via custom interface, I had put message boxes in the IDispatch’s functions and observed the same behavior. In case of VB client, it uses our IDispatch. In case of Python client, I observed that it is not using IDispatch but directly calls CoCreateInstance for our provided interface(here it’s IMyMath). It uses our registered type library. We can easily call QI in Python client to get desired interface pointer.
References:
1) Download Python 2.7.10(32bit)
2) Download comtypes extension
3) comtypes documentation
4) Python Client help on codeproject
Our sessions on why Java/.NET came and now why WinRT introduced, were really good. I enjoyed them and we got the clear idea “How should we start learning a technology and How it should be taught”. Thank you.
Note: Rename PythonClient to .py
Steps and Program By: Jeevan Gaikwad (UNIX 2014, WinRT 2015, RTR 2017)
Unix System Programs
Assignment by Bhagyashree Pandit (UNIX Dec 2013 batch)
Q : Why did you do this programs?
Bhagyashree : As UNIX was in the syllabus of my last semester, Theory as well as University practical. So, sir (Dr Vijay Gokhale) told in class to refer Advanced Programming in the UNIX Environment – By W. Richard Stevens (now referred as book), as it gives the practical idea of “The Design of the UNIX Operating System by Maurice J. Bach”.
So when I start reading this book, first I solved the practical assignments with the help of this book, after that sir told me to do programs given in this book, so I started solving the same and I finished the last chapter of the book last month only.
Q : How it helped you to understand UNIX operating system ?
Bhagyashree : Well, it’s worth in many ways. First, if you know UNIX, you can understand many other operating systems since UNIX seems to be as the base (or Mother ) of most operating systems (for eg: OSX ) and secondly, many servers runs on UNIX. Also, it is fun knowing stuff most people never heard of. It can never hurt to learn as much as your interest is peaked, since I am still a student.
Most importantly you realize ‘why’ we are doing the things inside the operating system as the way we are doing. While reading operating system algorithms in Bach, it always remains back of the mind that we have to provide ‘such and such’ system call to the application programmer using which application programmer is going to write his application.
And if application programmer is to get that built in behaviour via system call then operating system has to implement it. To implement that behaviour, all this is going on. That’s how the logical chain proceeds. That means as an application programmer, I just call a fork() to create a new process. While learning allocreg, attachreg etc. I keep that in mind.
Programs are uploaded here
Log of COM Aggregation Program
Client calling CoCreateInstance…
Outer Component’s DLL is ATTACHED.
DllGetClassObject().
CSumSubtractClassFactory::CTOR().
CSumSubtractClassFactory::QueryInterface().
CSumSubtractClassFactory::AddRef().
CSumSubtractClassFactory::Release().
CSumSubtractClassFactory::CreateInstance().
CSumSubtract::CTOR().
CSumSubtractClassFactory::CreateInstance(): Calling pCSumSubtract->InitializeInnerComponent.
CSumSubtract::InitializeInnerComponent(): Calling CoCreateInstance with CLSID_MultiplicationDivision.
Inner Component’s DLL is ATTACHED.
DllGetClassObject():.
CMultiplicationDivisionClassFactory::CTOR()
CMultiplicationDivisionClassFactory::QueryInterface()
CMultiplicationDivisionClassFactory::AddRef()
CMultiplicationDivisionClassFactory::Release()
CMultiplicationDivisionClassFactory::CreateInstance(): pUnkOUter Not NULL
CMultiplicationDivision: CTOR:.
CMultiplicationDivision: CTOR:.pIUnknownOuter!=NULL
CMultiplicationDivision::QI_NoAggreration : (this).
CMultiplicationDivision::AddRef_NoAggregation():
CMultiplicationDivision::Release_NoAggregation():
CMultiplicationDivision::AddRef_NoAggregation():
CMultiplicationDivision::Release_NoAggregation():
CMultiplicationDivisionClassFactory::Release()
CMultiplicationDivisionClassFactory::DTOR()
CMultiplicationDivisionClassFactory::Release() : delete this
CMultiplicationDivision::QI_NoAggreration : (this).
CMultiplicationDivision::AddRef_NoAggregation():
CMultiplicationDivision::Release_NoAggregation():
CSumSubtract::InitializeInnerComponent(): Calling m_pIUnknownInner->QueryInterface: IID_IMultiplication.
CMultiplicationDivision::QI_NoAggreration : (this).
CMultiplicationDivision: AR().
CSumSubtract::AddRef().
CSumSubtract::InitializeInnerComponent(): Calling m_pIUnknownInner->QueryInterface: IID_IDivision.
CMultiplicationDivision::QI_NoAggreration : (this).
CMultiplicationDivision: AR().
CSumSubtract::AddRef().
CSumSubtract::InitializeInnerComponent(): Successfully completed..
CSumSubtract::QI(): (this).
CSumSubtract::AddRef().
CSumSubtract::Release().
CSumSubtract::AddRef().
CSumSubtract::Release().
CSumSubtractClassFactory::Release().
CSumSubtractClassFactory::DTOR().
CSumSubtract::QI(): (this).
CSumSubtract::AddRef().
CSumSubtract::Release().
Client calling pISum->SumOfTwoIntegers…
CSumSubtract::SumOfTwoIntegers().
Client calling pISum->QueryInterface()
CSumSubtract::QI(): (this).
CSumSubtract::AddRef().
Client calling pISum->Release()
CSumSubtract::Release().
Client calling pISum->SubtractionOfTwoIntegers()
CSumSubtract::SubtractionOfTwoIntegers().
Client calling pISubtract->QueryInterface(IID_IMultiplication)
CSumSubtract::QI(): IID_IMultiplication: m_pIUnknownInner->QueryInterface(riid,ppv).
CMultiplicationDivision::QI_NoAggreration : (this).
CMultiplicationDivision: AR().
CSumSubtract::AddRef().
Client calling pISubtract->Release()
CSumSubtract::Release().
Client calling pIMultiplication->MultiplicationOfTwoIntegers()
CMultiplicationDivision::MultiplicationOfTwoIntegers()
Client calling pIMultiplication->QueryInterface(IID_IDivision)
CMultiplicationDivision: QI().
CSumSubtract::QI(): IID_IDivision: m_pIUnknownInner->QueryInterface(riid,ppv).
CMultiplicationDivision::QI_NoAggreration : (this).
CMultiplicationDivision: AR().
CSumSubtract::AddRef().
Client calling pIMultiplication->Release()
CMultiplicationDivision: R().
CSumSubtract::Release().
Client calling pIDivision->DivisionOfTwoIntegers()
CMultiplicationDivision::DivisionOfTwoIntegers()
Client calling pIDivision->Release()
CMultiplicationDivision: R().
CSumSubtract::Release().
SafeInterfaceRelease().
DllCanUnloadNow():.
DllCanUnloadNow(): FAIL
DllCanUnloadNow().
DllCanUnloadNow(): FAIL..
Inner Component’s DLL is DETACHED.
Outer Component’s DLL is DETACHED.
download : aggregation Client Flow
By Unmesh Joshi
unmesh.joshi126@gmail.com