Page 1 of 1

Scripting and external dll

Posted: Sat Oct 06, 2018 1:23 pm
by Butterbelly
Hi

have asked this on astroart forum and not got very far
Then thought this may be the best option - SHARPCAP

is it possible to interact with an external dll from the script language - the reason I ask is I would like to control my Hitecastro power hub - specifically the dew heaters from scripting - I have done a little research but it is 5 years since I did any serious programming with windows and com etc so forgive my simple questions.


Hitecastro supply a dll and quote


Using mhpCOM.
mhpCOM can be used with any programming or scripting language which
supports COM interop. Examples are the .net languages from Microsoft. Visual
Basic.net, Visual C# .net and Visual C++ can be downloaded freely from the
Microsoft Visual Studio Express site. Many other languages and tools will also
be eminently suitable. Scripting languages such as VBScript or JavaScript can
also leverage the functionality of mhpCOM.


an example use from vbscript would be

Dim mhp
Set mhp = CreateObject(“mhpCOM.mhpCOM”)

or


Dim mhp
Set mhp = CreateObject(“mhpCOM.mhpCOM”)
mhp.Heater 3, 75



My question is

Is this easy from scripting?
If not what do I need to get into to achieve this?
Any other question that I cant think of due to my ignorance!?

many thanks

Keith Butterworth

Re: Scripting and external dll

Posted: Sat Oct 06, 2018 8:08 pm
by admin
Hi Keith,

I think what you need is...

Code: Select all

from System import Activator
from System import Type
mhp = Activator.CreateInstance(Type.GetTypeFromProgID("mhpCOM.mhpCOM"))
mhp.Heater(3,75)
I'm fairly sure the first 3 lines are correct - the last is my guess based on your sample code - it may need tweaking.

cheers,

Robin

Re: Scripting and external dll

Posted: Sun Oct 07, 2018 7:12 am
by Butterbelly
Thanks for replying - I will try that out after updating and installing necessary dll
Cheers Keith Butterworth

Re: Scripting and external dll

Posted: Mon Oct 08, 2018 10:34 am
by Butterbelly
Hi no joy when I tried the commands
I got an error message which I have attached - I tried 1 or 2 variations of the syntax and always had the same error
.
The first 2 commands were accepted.

When I tried the smart context sensitive menus on the command it didn't seem to have picked anything up !?


Any suggestions

Re: Scripting and external dll

Posted: Mon Oct 08, 2018 4:03 pm
by admin
Hi,

it looks like the code

Code: Select all

Type.GetTypeFromProgID("mhpCOM.mhpCOM")
is not returning a valid object - that means that either the mhpCOM.mhpCOM string is incorrect or the DLL providing that object hasn't been registered correctly.

The following code demonstrates the basic technique with a COM object that will be correctly registered on your system

Code: Select all

from System import Activator
from System import Type
test = Activator.CreateInstance(Type.GetTypeFromProgID("Shell.Application"))
test.BrowseForFolder(0, "hello", 0)
This wlll show a folder browser window.

You may find that registering your dll for COM helps fix your original problem - from an administrative command prompt run

Code: Select all

regsvr32 "<full path to your mhpcom.dll>"
Robin

Re: Scripting and external dll

Posted: Mon Oct 08, 2018 4:47 pm
by Butterbelly
Robin
again thanks for your help
I will try your test code that should work and go from there
cheers
Keith