exchanging data between programs in memory

Share your advanced PureBasic knowledge/code with the community.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

exchanging data between programs in memory

Post by blueznl »

Code updated For 5.20+

here's how to do it:

Code: Select all

; sender
;
mapped_h = CreateFileMapping_($FFFFFFFF,0,#PAGE_READWRITE,0,1024,"shared")
mapped_p = MapViewOfFile_(mapped_h,#FILE_MAP_ALL_ACCESS,0,0,1024)
;
w_main_nr = 1
w_main_h = OpenWindow(w_main_nr,1024+10,10,100,100,"sender",#PB_Window_SystemMenu)

ListViewGadget(1,1,1,WindowWidth(0)-1,WindowHeight(0)-1)
AddGadgetItem(1,-1,"sender")
AddGadgetItem(1,-1,"")
AddGadgetItem(1,-1,Str(mapped_h))
AddGadgetItem(1,-1,Str(mapped_p))
;
Repeat
  event = WindowEvent()
  If event = 0
    Delay(20)
    n = n+1
    If n = 10
      n = 0
      nn = nn+1
      PokeL(mapped_p,nn)
      SetGadgetItemText(1,1,Str(PeekL(mapped_p)),0)
    EndIf
  EndIf
Until event = #PB_Event_CloseWindow

( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
dmoc
Enthusiast
Enthusiast
Posts: 739
Joined: Sat Apr 26, 2003 12:40 am

Post by dmoc »

And for another example: click here
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

whoooohaaaaaa

totally overlooked yours and others, i wasn't searching for 'filemapping' so didn't run into your code!

that should have saved me some time :?

oh well...

viewtopic.php?t=11491
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Post by Rings »

Global Shared Memory,
including Sources,
Found in PBOSL
SPAMINATOR NR.1
Post Reply