Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / COM / September 2008



Tip: Looking for answers? Try searching our database.

ActiveX EXE - Share global vars with mult. apps?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JohnJohn - 20 Sep 2008 21:51 GMT
Hello.

The company I'm working for is using VB6 for several applications.  I need
to be able to set up the following scenario:

App1: Create an instance of an ActiveX application, then set the values of
several global variables.

App2, App3, App4...AppN: Retrieve the instance of the ActiveX application
created by App1, and retrieve the values of the global variables.

Easy-enough concept.  But I'm not sure if I'm setting my instancing in the
ActiveX EXE project I've created, or if I'm using the GetObject, CreateObject
calls incorrectly, or whether I could even use early binding in this case.  
But everything I have tried (namely every possible value for instancing),
always creates a NEW instance of the the ActiveX component, with a brand new
set of variables.

I can't seem to find any info on the web that will help me figure this out.  
And maybe I'm asking too much.  :)

Thanks for any help!
John
Tony Proctor - 22 Sep 2008 16:40 GMT
You need to run dcomcnfg.exe and change the Identity settings John. By
default, each separate client account gets it's own copy of the ActiveX EXE
and it then runs under their same account. If you set a single explicit
account in the Identity field for the ActiveX EXE then all your client apps
will share the same instance

You might also have to change the 'Authentication Level' to None

When you get the list of classes up in dcomcnfg, scroll down to the class
representing your EXE. There should only be one, and it doesn't matter which
one because it's actually representing the whole of the EXE.

   Tony Proctor

> Hello.
>
[quoted text clipped - 22 lines]
> Thanks for any help!
> John
Ken Halter - 23 Sep 2008 06:19 GMT
> Hello.
>
> I can't seem to find any info on the web that will help me figure this
> out.
> And maybe I'm asking too much.  :)

Are all apps running on the same PC? If so, register the AX.exe in the ROT
and you're set.

For a bit of sample code, see:

Shared global data between threads
http://groups.google.com/group/microsoft.public.vb.general.discussion/msg/a9acda
4941a44293


I haven't tried that code, but it looks complete... mine's similar to
that... but instead of hard-coding the app and class IDs, I have VB figure
that stuff out. So, with this sample, change:...

If CLSIDFromProgID(StrPtr("AXExeLib.CDataClass"), GUID(0)) = 0 Then

...To....

sAppID = App.EXEName & "." & TypeName(Me)
If CLSIDFromProgID(StrPtr(sAppID), GUID(0)) = 0 Then

...so you can copy/paste the same code into another app without changing
anything at all...

And, here's a typical "snip" to get things going....

  On Error Resume Next
  Set TheObject = GetObject(, "YourApp.YourClass")
  On Error GoTo 0 'or the nearest error handler
  If TheObject Is Nothing Then
     Set TheObject = New YourClass
  End If
Tony Proctor - 23 Sep 2008 09:24 GMT
I did wonder, Ken, whether he meant a single instance of an object from the
component (i.e a singleton) or just a single instance of the EXE. He used
the words "instance" in both contexts. Well, at least he now has answers for
both  :-)

   Tony Proctor

>> Hello.
>>
[quoted text clipped - 32 lines]
>      Set TheObject = New YourClass
>   End If
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.