Send string between apps
Send string between apps
Hi everyone
I want send big string variable from app1 to app2, what is the best or fastest way?
I want send big string variable from app1 to app2, what is the best or fastest way?
Re: Send string between apps
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: Send string between apps
If your data fits in one packet (1500 bytes)
Use UDP.
It is much faster and a loss on the same PC is nearly impossible.
It is also possible with larger datas, but then you need to handle the incomimg data stream.
Use UDP.
It is much faster and a loss on the same PC is nearly impossible.
It is also possible with larger datas, but then you need to handle the incomimg data stream.
Re: Send string between apps
Thanks but I mean on local system, something like share string variable between two program
My string variable is over 600 KB and updated every second in app1,after each string update i want send it (share) with app2 to process it.
Write and read from file is one basic way but i want faster way if possible.
My string variable is over 600 KB and updated every second in app1,after each string update i want send it (share) with app2 to process it.
Write and read from file is one basic way but i want faster way if possible.
Re: Send string between apps
We told you already the easiest way on a local PC
Use localhost (127.0.0.1) as address and choose a free port.
As alternative you have to implement shared memory, which is far more complicated.
Use localhost (127.0.0.1) as address and choose a free port.
As alternative you have to implement shared memory, which is far more complicated.
Re: Send string between apps
Already considered to work with 1 app and to outsource the tasks to the threads...
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: Send string between apps
Hi Wolf,
See Windows Services & Other Stuff
- \Windows_Services_Other_Stuff_SRC\Other_Stuff\CopyShare\...
NB*: Includes SendMessage text example and Shared Memory text and image examples.
See Windows Services & Other Stuff
- \Windows_Services_Other_Stuff_SRC\Other_Stuff\CopyShare\...
NB*: Includes SendMessage text example and Shared Memory text and image examples.
Re: Send string between apps
If you don't like tcp, just write it to Myfile4u.txt.
Then the reader opens and reads and clears it.
Myfile4u.0.
Then the reader opens and reads and clears it.
Myfile4u.0.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Re: Send string between apps
On windows API you can use
You need the window handle, which you can get from
And you can handle the recieve by a windows callback and checking for #WM_COPYDATA.
Code: Select all
SendMessage_(hwnd, #WM_COPYDATA, #Null, *CopyData)
Code: Select all
EnumWIndows_(...
Proud supporter of PB! * Musician * C64/6502 Freak
-
- Always Here
- Posts: 6425
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Send string between apps
See netmaestro's example here: viewtopic.php?t=29781
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: Send string between apps
Thank you all for your solutions.
After test all, i think best one for me and my program is using SendMessage with #WM_COPYDATA.
So thanks again @JHPJHP & @oreopa & @IdeasVacuum for SendMessage codes and examples, especially @JHPJHP for great CopyData example code in "Windows Services & Other Stuff" topic, thanks man
After test all, i think best one for me and my program is using SendMessage with #WM_COPYDATA.
So thanks again @JHPJHP & @oreopa & @IdeasVacuum for SendMessage codes and examples, especially @JHPJHP for great CopyData example code in "Windows Services & Other Stuff" topic, thanks man
Re: Send string between apps
Using the clipboard... send and detect.
Yeah I know, but keep in mind ... Leonardo da Vinci was also an autodidact.
Re: Send string between apps
That’s not a good way. The user wouldn’t appreciate it if something they have on the clipboard disappears.Joris wrote:Using the clipboard... send and detect.
Re: Send string between apps
It's just a possibility. Besides let Wolf decide what is useable and good.wombats wrote:That’s not a good way. The user wouldn’t appreciate it if something they have on the clipboard disappears.Joris wrote:Using the clipboard... send and detect.
What copy/paste does, is mostly well known, so...
Yeah I know, but keep in mind ... Leonardo da Vinci was also an autodidact.
Re: Send string between apps
wombats, good question. Therefore I will ask here: how can I save/copy temporarily the global buffer (if not empty) with userdata in other place? Not destroy/clear, but make backup userdata (pictures, links, text etc.) somewhere in available memory block. If I need use the global buffer for my things for a short time. Then to be able to recover userdata. And user will not see changes.
There is some code for analys the global buffer content (to determine type of text):
There is some code for analys the global buffer content (to determine type of text):
Code: Select all
OpenClipboard_(0)
lR = EnumClipboardFormats_(lR)
Select lR
Case #CF_TEXT
Debug "Text"
hStrPtr = GetClipboardData_(lR)
MessageRequester("ClipBoard Text", PeekS(hStrPtr,-1,#PB_Ascii), 0)
Case #CF_BITMAP
Debug "Bitmap Picture"
Case #CF_METAFILEPICT
Debug "Meta-File Picture"
Case #CF_SYLK
Debug "Microsoft Symbolic Link (SYLK) data."
Case #CF_DIF
Debug "Software Arts' Data Interchange information."
Case #CF_TIFF
Debug "Tagged Image File Format (TIFF) Picture"
Case #CF_OEMTEXT
Debug "Text (OEM)"
hStrPtr = GetClipboardData_(lR)
String.s = PeekS(hStrPtr,-1,#PB_Ascii)
OemToChar_(@String, @String)
MessageRequester("ClipBoard Text", String, 0)
Case #CF_DIB
Debug "DIB Bitmap Picture"
Case #CF_PALETTE
Debug "Colour Palette"
Case #CF_PENDATA
Debug "Pen Data"
Case #CF_RIFF
Debug "RIFF Audio data"
Case #CF_WAVE
Debug "Wave File"
Case #CF_UNICODETEXT
Debug "Text (Unicode)"
hStrPtr = GetClipboardData_(lR)
MessageRequester("ClipBoard Text", PeekS(hStrPtr,-1,#PB_Unicode), 0)
Case #CF_ENHMETAFILE
Debug "Enhanced Meta-File Picture"
Case #CF_HDROP
Debug "File List"
Case #CF_LOCALE
Debug "Text Locale Identifier"
Default
Debug "Unknown encoding or data = " + lR
hStrPtr = GetClipboardData_(lR)
MessageRequester("ClipBoard Text", PeekS(hStrPtr,-1,#PB_Unicode), 0)
EndSelect
CloseClipboard_()