Link to home
Start Free TrialLog in
Avatar of carloslimajr
carloslimajr

asked on

VB6 Shared Memory

I am building an app using vb6. In this app I have an amount of information that needs to be shared between others vb6 app running under the same machine. The data to be shared are some user data type arrays. The app clients must be able to read and write the arrays asynchronously. How is the best way to implement it and get the best performance?

I appreciate any kind of sample code. For example, it could have a main process that hold the data and serve the clients. Client A write a variable in the server process and client B read it.

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

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
To exchange data beteween applications you can use getsetting and savesetting
Getsetting and savesetting use the registry to store data.


This sample creates the following key in the registry :
HKCU\Software\VB and VBA Program Settings\Project1\Settings

Under "Settings" it creates the additional value
"Hey,I love Microsoft"


Private Sub Form_Load()
zzz = "Hey,I love Microsoft"
'Set some data to registry
SaveSetting App.Title, "Settings", "firmName", zzz '  "App.Title" contains the variable  "Project1"


'read some data from registry
qqq = GetSetting(App.Title, "Settings", "firmName", "sorry, but the registry entry 'firmName' doesn't exist")
MsgBox qqq
' RESULT : a message box pops up with the text - - -> Hey,I love Microsoft
End Sub




'Annotation:
'The last parameter of the GetSetting() function allows you to supply a DEFAULT value
'if the requested registry entry is not found...

'Counter = GetSetting(App.Title, "Settings", "Counter", "-1")
'If Counter = "-1" Then        ' no value in registry
Avatar of carloslimajr
carloslimajr

ASKER

I wouldn't like to use files or registry to share the data because I think the overhead will be huge. The data must be exchanged through process in memory.
>>The data must be exchanged through process in memory.

You have to go the ActiveX EXE way as I pointed too.
I agree with emoreau, you should go down the ActiveX Exe. This will enable you to write a 'server' application that other VB apps can get data from.
I developed a piece of code using an EXE ActiveX. It worked very fine when I compile the activex with 'Thread pool = 1 thread', but I observed that when I compile the code with 'Thread per Object' or 'Thread pool > 1 thread' set, my public variables are cleaned (they really are reinitialized when a new instance is created). My 'data server process' as we could call him, will be accessed from about 300 another processes per minute on the same machine.

The questions are:

Wouldn't be better compile the EXE ActiveX with Thread per Object or Thread pool > 1 thread option set ?

Using Thread pool = 1 thread, Will these access (read and write) be asyncronous or serialized ?
SOLUTION
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