🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #10465

Re: How to catch mouseclicks from another application?

#10465
From: Remy Lebeau (TeamB)
Date: Fri, 09 Apr 2004 18:04
64 lines
3991 bytes
"Henk" <h.van.winkoop@wxs.nl> wrote in message
news:40769c18$1@newsgroups.borland.com...

> Well, I feel very stupid. I thoroughly studied this
> CreateFileMapping() and MapViewOfFile() stuff but
> I feel like having a box with nuts and bolts but having
> no idea what to construct with it.

Simply define a structure that contains the values you want to share, and
then create a named mapping that is the size of the structure.  By assigning
a name to the mapping, every instance of the DLL will get a pointer to the
same mapping, thus sharing the same memory.  When your application fills in
the values, they will be available to the other instances of the DLL.

> Now I start to derail. (I know you must be right) talking
> about: >"of other instances of the DLL that are injected
> into other processes" I do not have the slightest idea what
> is ment by this.

You need to learn how DLLs work in general then.

A DLL is nothing more than a block of memory and functions that is injected
into the address space of the calling application.  Applications cannot
access each other's memory directly, that is why you cannot hook another
process directly and must use a DLL.  Only a DLL will be able to directly
access the memory of another process, as it essentially becomes another part
of the process's own memory.  That is why every process must get its own
copy of the DLL loaded.    The OS will handle that part for you.

> I see an 'instance of the DLL' as my MouseHook-DLL
> functions that are loaded by my MainApplication somewhere
> into computer memory.

You are thinking too small.  An instance of the DLL will be loaded into ALL
processes, not just your own application only.  Every process will get its
own copy of the DLL functions and data loaded into computer memory.

> So what is ment by these 'other instances' and what is ment
> by these 'other processes'?

Every program is run in its own process.  Every process will load a new
instance of the DLL.

You really need to learn how the OS works in general.  There are entire
chapters on Processes and Threads and DLLs in the Win32 API documentation.
I strongly recommend that you read them before continuing.

> If , for example, I mouse-click somewhere in an Excel-Application
> residing somewhere on my desktop, does that create another
> 'instance of my MouseHook-DLL' meaning does it create a copy
> of my MouseHook-DLL in memory and execute it?

Yes.

> What is the main difference between a mouse-click on my
> Borland-Builder generated MainApplication window (which
> has 'hooked' the 'MouseProc' function) and a mouse-click on
> any other window available-on-my-desktop?

The click is occuring in a different process.


Gambit
Technical Details
Message-ID: <4076e5a0$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <407421ef@newsgroups.borland.com> <40743aad$1@newsgroups.borland.com> <40754399$1@newsgroups.borland.com> <40758801$1@newsgroups.borland.com> <4075a4df$1@newsgroups.borland.com> <4075b6bd$1@newsgroups.borland.com> <4076476e$1@newsgroups.borland.com> <40764eac$1@newsgroups.borland.com> <40769c18$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,e0858ea1c0821ca
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-04-09 11:09:45 PST
From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <407421ef@newsgroups.borland.com> <40743aad$1@newsgroups.borland.com> <40754399$1@newsgroups.borland.com> <40758801$1@newsgroups.borland.com> <4075a4df$1@newsgroups.borland.com> <4075b6bd$1@newsgroups.borland.com> <4076476e$1@newsgroups.borland.com> <40764eac$1@newsgroups.borland.com> <40769c18$1@newsgroups.borland.com>
Subject: Re: How to catch mouseclicks from another application?
Date: Fri, 9 Apr 2004 11:04:30 -0700
Lines: 66
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 67.22.138.253
Message-ID: <4076e5a0$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1081533856 67.22.138.253 (9 Apr 2004 11:04:16 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail