Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
8
Erster Beitrag:
vor 3 Monaten, 1 Woche
Letzter Beitrag:
vor 3 Monaten, 1 Woche
Beteiligte Autoren:
André Labuschagné, Tor-Bjarne, Yogi Yang, Arie, Steven Sitas, DW

Sharing Data In RAM Between Apps

Startbeitrag von André Labuschagné am 16.03.2017 19:21

Hi All

Is that possible? I want to store a numeric in a variable in one app and then read that variable in another app. Any way to do that with WD?

Andre

Antworten:

Hi Andre,
you can use shared memory zones

https://help.windev.com/en-US/?1000018934&name=Shared_memory_zones

Steven Sitas

von Steven Sitas - am 16.03.2017 19:42
Steven - stunning - thanks a ton. I sometimes have a problem finding these functions with Frenglish and all - no idea what they will call it.

These means I can share small bits of data between apps. Good.

Andre

von André Labuschagné - am 16.03.2017 19:56
Registry is another option

von Arie - am 16.03.2017 20:05
Arie - getting a -1 returned on fMemOpen - no idea what this means. I can only guess that it is an administrator rights issue. This could be a show stopper.

Andre

von André Labuschagné - am 16.03.2017 21:02
Andre,

I found that you can not count on memory zones. Best way is to write it to a file of registry.

I have 2 apps that deal with QuickBooks 1 receives the change message from quickbooks the other process it. When the receiver gets the call I use Postmessage to click a hidden button in the second app (Processor) that will process the changes.

When process opens, I write the handle of it in a text file. Every time the change event from Quickbooks happen it reads that same file and if there is a handle number it calls the postmessage if not it will say closed and nothing will process.

Set the handle

PROCEDURE gp_SetHandle(bEnable is boolean=True,sWinName is string = "WIN_Table_Account")

//Get the directory of the user data
sDirectory is string

sDirectory = fGlobalDirUser()
//Make the full file path to save to
sMyFile is string = sDirectory+"\CSI\QB Ticket.txt"


Text is string

IF fFileExist(sMyFile) THEN
Text = fLoadText(sMyFile)
ELSE
fCreate(sDirectory)
END


sBtnHandle is string
IF bEnable THEN
sBtnHandle=Handle(sWinName+".BTN_Button1")
ELSE
sBtnHandle="Closed"
END

OutPutText is string = gclParam:LineWrite(Text,"Handle",sBtnHandle)
fSaveText(sMyFile,OutPutText)


result is the text file looks like this :
Handle=123456 or Handle=Closed

When I close the processor app I write to the file that it is closed.

DW

von DW - am 17.03.2017 00:25
Hello,

I think it would be better to use PostMessage Windows API for such communications.

Another more suitable way would be to use MemoryMapped File Windows API .

The second approach is a bit daunting so please check this small VB6 sample code to understand as to how to use MemorMapped File.
http://www.vbforums.com/showthread.php?696123-VB6-MMapper-Memory-Mapped-File-Demo

HTH

Yogi Yang

von Yogi Yang - am 18.03.2017 05:53
Hi

Inter Process Communication (IPC) can be tricky, for example if App1 tries to communicate with App 2 this might not work as App 2 is stared in a elevated state (as administrator) as an example.

Also perhaps an impact could be if App 1 is 32 Bit and App 2 is 64, having said that I did a study a couple of years ago since I wanted App 1 to communicate with App 2.

A part from the obvious (communicate via a HF-table / Text file), there`s several ways of IPC.

Actually I rented Fabrice Harari to make me a class for IPC, not quite sure who holds the copyright, but I have no problem sharing this code if it`s ok with Fabrice Harari :)

You can also with WinDev make a small Tcp/Ip Server/client on the same computer, but for sharing over a network other challenges may apply.

Or what about a web-service holding variable values (in a table) and let App 1 to App 2 share info?

Also like to mention ZeroMQ as probably the best free messaging tool in the marked for the moment, and here here`s also free code in the PC soft repository to handle this great free product.

Cheers
Tor-Bjarne

von Tor-Bjarne - am 18.03.2017 08:44
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.