how to run the program only once (windows)
hmmm... does that mean datasection is always maintained in memory, or no, perhaps better put: does that mean that the address you pass from one program to another is valid and stays valid? i thought you couldn't rely on 'physical' adresses being the same to all programs... or is this ok these days on windows?
( 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... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
When you use adresses (for example a label) this adress refers to your process. So if it's the same program (what i know from the ExeFile) 2 identic adresses point to the same data.
I think this is "relative" adressing but i don't really know. :roll:
I don't know neither if you can get the physical adresses
Dri
I think this is "relative" adressing but i don't really know. :roll:
I don't know neither if you can get the physical adresses
Dri
now let's up the challenge: let's create two DIFFERENT programs that need to access the same data
preferably by allocating a piece of fixed memory?
i've been looking through the win32 api and i'm pretty sure there must be some way, but haven't found it yet...

i've been looking through the win32 api and i'm pretty sure there must be some way, but haven't found it yet...
( 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... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
There is already a userlib for this I think : GlobalSharedMemory (by Rings) http://pbosl.purearea.net/index.php?site=Libs . It uses file mapping IIRC.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
ha solved it 

( 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... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
it's also another alternative to check what program came first, just see if you can open a filemapping, if not there's no instance running yet 
see here...
viewtopic.php?t=17542

see here...
viewtopic.php?t=17542
( 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... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
I still don't know what's wrong with the single-line sempahore example, it
works just fine for me with Win 98se, ME, 2K and XP. (I couldn't make it
fail under Win98se as reported here, maybe the steps to make it do so
could be posted so I can see for myself?).
works just fine for me with Win 98se, ME, 2K and XP. (I couldn't make it
fail under Win98se as reported here, maybe the steps to make it do so
could be posted so I can see for myself?).
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
That's what I did too -- a sempahore under Win98se and I made the app
crash (by doing a GetClipboardText when the clipboard had >64K) and
I was still able to re-run it again, thus I believe the semphore died when
the app crashed. Anyway, that's my experience with it, and why I still
choose to use it to prevent multiple instances. <Shrugs>.
crash (by doing a GetClipboardText when the clipboard had >64K) and
I was still able to re-run it again, thus I believe the semphore died when
the app crashed. Anyway, that's my experience with it, and why I still
choose to use it to prevent multiple instances. <Shrugs>.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
an laternative may be a named pipe, playing with that now
( 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... )
( The path to enlightenment and the PureBasic Survival Guide right here... )