Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2006-03

Atom like feature in FreePascal

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

MAGENTA LTD

I'm interest on an OS independed (or at least Linux and MacOS), Windows ATOM like* feature, supported by FreePascal. Most similar feature found is environment variables which are accessed by GetEnvironmentVariable() function. There is Get function but could not find any Create or Set. Besides documentation, already checked osutilsh.inc file in which GetEnvironmentVariable() is declared. I think if there was any related functions would be stored in this same interface file, right?

What I need to do:
I need to set a system wide flag so to determine if specific tasks are executed in current system login session. If user log off or restart, then I could know this by not finding flags in memory. Flags should not be visible to any other program (enumeration-proof), unless it is called by it's name.

Any directions would be most appreciated.

* Windows atoms are like system variables which can be used as flags or as counters. This is supported by a group of Windows API functions, such as "GlodalAddAtom, GlobalFindAtom, GlobalDeleteAtom". Atoms cannot be enumerated or accessed if caller do not know it's specific name. So, it a kind of safe way to pass flags or information between programs and instances of your apps.

Regards, Panagiotis
-------------------
OS: Linux, Knoppel, Knoppix localized distribution IDE: Lazarus (revision 8985)
FreePascal revision: 3010

Felipe Monteiro de Carvalho
to Jeff Pohlmeyer

Hello,

My advice about how to support this would be creating a class that has Atom functions and implements them separetely on each platform.

So far we saw here that winapi and X11 have Atom functions. There is probably something equivalent for Carbon on Mac OS X, you just need to search Apple docs.

This is a case similar to TTrayIcon, because both components need a separete implementation based on the OS, and not really per widgetset. I mean, let's say you use gtk on windows, you will still want to implement Atom function using the windows api, because x11 isn't available there. (suposing gtk doesn't have atom functions)

thanks,

Felipe Monteiro de Carvalho
MAGENTA LTD
to Jeff Pohlmeyer: Maybe this? http://www.xfree86.org/4.0.1/XInternAtom.3.html

Yes, this is what I need. ATOMS are implemented in xlib file which you have just to include.
Here are a couple of functions to use ATOMs directly for anyone interest in:

// if exist a specific ATOM
function spExistATOM( cAtomName: string ): boolean;
var
   cDisplay: string;
   Display: PDisplay;
begin
     cDisplay := GetEnvironmentVariable( 'DISPLAY' );
     Display := XOpenDisplay( pchar( cDisplay ) );
     if XInternAtom( Display, cAtomName, true ) > 0 then Result := true
     else Result := false;
end;
// create ATOM
function spCreateATOM( cAtomName: string ): integer;
var
   cDisplay: string;
   Display: PDisplay;
begin
     cDisplay := GetEnvironmentVariable( 'DISPLAY' );
     Display := XOpenDisplay( pchar( cDisplay ) );
     if not spExistATOM( cAtomName ) then Result := XInternAtom(
Display, ATOM_NAME, false )
     else Result := XInternAtom( Display, cAtomName, true );
end;

Regards, Pamagiotis

Earlier message 13 lines
-----Original Message----- From: Jeff Pohlmeyer Sent: Friday, March 24, 2006 1:29 PM To: Cc: Subject: RE: Atom like feature in FreePascal > I'm interest on an OS independed (or at least Linux and MacOS), > Windows ATOM like* feature, supported by FreePascal. Maybe this? http://www.xfree86.org/4.0.1/XInternAtom.3.html