Link to home
Start Free TrialLog in
Avatar of alexkwok
alexkwok

asked on

Passing a picture object between an ActiveX exe and a regular exe.

What I have right now is a standalone activex exe that acts as a server for programs to connect to using GetObject().  I am passing data between the programs, but I can't pass any VB pictures between them because I get an error

"Method of 'GetPicture' of object '_test' failed."

Where GetPicture is the function/property I am calling to get the picture and 'test' is the class module in the activex exe.  The activex exe project is here: http://www.vbforums.com/attachment.php?s=&postid=1765076

and then make a standard exe with this code:
----------------------------------------------------
Private Sub Form_Load()
Dim obj As Object

Set obj = GetObject(, "TestEXE.Test")
Set Me.Picture = obj.getpicture
End Sub
----------------------------------------------------

Compile the ActiveX exe and run it.  When you run the StandardEXE part, you will see the error.

Does anyone know of a way around this, or possibly another solution?
Avatar of mladenovicz
mladenovicz

Avatar of alexkwok

ASKER

I don't want to work with byte arrays unless I absolutely need to.
getobject has 2 parameters .. u r specifying the second parameter .. so no pathname is specified ..

This is what MSDN says ...
If PathName is a zero-length string (""), GetObject returns a new object instance of the specified type. If the PathName argument is omitted, GetObject returns a currently active object of the specified type. If no object of the specified type exists, an error occurs.

So my question is .. is ur activex exe running when u test from the client machine ..
one more question ... y not just use the "NEW" keyword and create a ne instance of the object instead of getobject??
This whole activex exe thing works right now.  I'm not trying to create a new instance, I am getting the current existing object so it can be used as a server for programs to GetObject() into.  I'm 100% sure that it is working as it should because it's only possible for the server to start once.

My problem isn't "ActiveX cannot create object" because I am not getting that error.
And I know you can just open another copy of the program, but I meant without doing that, the program will not spawn different copies of itself.
I did what I wanted to do in a different way, so I'll have my points refunded.
@Rejojohny

first post: Yes the activex exe is running.

for second post: I'm not trying or wanting to create a new instance.  I wanted a way to have a single program that acts as a server for many other "clients" to GetObject() into.
In any case, a bigger part of the project was taking an hIcon and converting it to a IPicture and sending that IPicture over to the client exe.  Sending only the hIcon didn't work because the hIcon was destroyed after use (from another program), so I just used DuplicateIcon() API to maintain a copy of it, and sent that copy over.  I didn't really send the picture over because that just wasn't possible (limitations with VB and threading) and byte arrays ruined the alpha bits of the icon, so sending the hIcon was a much better solution anyways.
is there a specific reason for u to use the getobject .. like some variables to be shared between multiple clients or something like that because the same can be acheived by specifying the instancing property of ur class as "Multiuse" .. the one instance of your object created would provide multiple objects to multiple client applications without duplication of resources or global data.
I made a C dll that hooks the system tray.  I made a program that took data from the dll and process it so that the icons etc can be accessible from another VB program that wants to.
ASKER CERTIFIED SOLUTION
Avatar of Netminder
Netminder

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial