Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

passing a GUID byref?

If you have a question or need help, this is the place to be.
Post Reply
thug
Plugin Developer
Posts: 64
Joined: Sat Jul 22, 2006 2:37 pm
Location: Australia

passing a GUID byref?

Post by thug »

HI,

Im looking to write a plugin for eventghost.

But i'm a bit of a noob...

I need to pass the address of a variable, that is a GUID, to a dll function.

as in 'c++'

GUID MyGuid;
SomeDllFuntion(&MyGuid);


this is what I have so far....

Code: Select all

from eg.WinAPI.GUID import GUID

    def __start__(self):

        Mydll = WinDLL('somedll')

        MyGuid = GUID

        Mydll.SomeDllFunction(byref(MyGuid))

        print (MyGuid)

but when the plugin starts i get :-

Code: Select all

3:30:22 PM   File "C:\Program Files\EventGhost\eg\TreeItems\PluginItem.py", line 107, in StartPlugin
3:30:22 PM   File "plugins/NewPlugin/__init__.py", line 35, in __start__
3:30:22 PM TypeError: byref() argument must be a ctypes instance, not '_ctypes.StructType'
and without the byref() i get :-

Code: Select all

3:33:22 PM ArgumentError: argument 1: <type 'exceptions.TypeError'>: Don't know how to convert parameter 1
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Post by Bitmonster »

All ctypes must be instantiated to function as a buffer. Otherwise the identifier stays a "type".

So:
MyGuid = GUID
means, that you assign another name (MyGuid) to the "type" of GUID.

But:
MyGuid = GUID()
means, that you create a new instance of the type GUID and that's what you want.

EDIT:
To show the actual content of a ctype, you need to use the field "value" of a it. So I assume you need to write:
print MyGuid.value
thug
Plugin Developer
Posts: 64
Joined: Sat Jul 22, 2006 2:37 pm
Location: Australia

Post by thug »

Awesome, That did the trick!

static ulong URAStar;

URAStar+=5000;
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Post by Bitmonster »

Excuse my curiosity:
What kind of plugin are your writing?
Post Reply