service - variables + functions

service - variables + functions

Post by Chew Lek W » Sat, 14 Feb 2004 19:59:48


Hi,

i'm writing a windows service which has certain variables and functions tht
i would like other process/application to call. how do i do tht ?


thanx in advance.
 
 
 

service - variables + functions

Post by Georgy Mal » Sat, 14 Feb 2004 23:23:12

Hello, Chew Lek Wah!
You wrote on Fri, 13 Feb 2004 18:59:48 +0800:

CLW> Hi,

CLW> i'm writing a windows service which has certain variables and functions tht
CLW> i would like other process/application to call. how do i do tht ?

The simplest way to establish communication with service is COM.

CLW> thanx in advance.

WBR,
Ge ***

 
 
 

service - variables + functions

Post by lekwa » Sun, 15 Feb 2004 16:41:11

thanx for your reply. Can you pls elaborate more ? since this is the
first time i'm doing this sort of things, wht other methods can i use
so i can have more options to try and learn.
 
 
 

service - variables + functions

Post by Arkady Fre » Sun, 15 Feb 2004 21:33:29

Put variables in share section of dll where you'll write the functions you
want to be used by other processes
Arkady



tht
 
 
 

service - variables + functions

Post by Kirk Ferdm » Mon, 16 Feb 2004 08:53:40


tht

Any IPC (i.e. interprocess communication mechanism) will do. You have a
variety to pick from: shared section, memory mapped files (MMF), RPC, DCOM,
pipes, sockets, etc.

I would say that DCOM is the easiest way because you won't have to think
about marshaling data between processes. I assume that you know that each
process has its own memory space and thus you can't "simply share" pointers.
Just expose a COM object from you service and let the client to call
CoCreateInstance to obtain the pointer.

As a viable alternative for speed-effective cases you can consider MMF.
Check MSDN on OpenFileMapping/CreateFileMapping and MapViewOfFile. Note
though that you won't have certain benefits of DCOM infrastructure: you'll
have to marshal the data in and out yourself, and if you need to impersonate
the client you'll have to roll your own version of impersonation.

You can consider using pipes as well. See MSDN on CreateNamedPipe and
CreateFile. Pipes support impersonation, but you still have to marshal the
data.

I'm sure others will mention how to implement shared section in a DLL and
load it into both process. I'd rather discourage you from using this method.
It's more prone to bugs, doesn't scale well, has lots of security
ramifications, etc.

-Kirk
 
 
 

service - variables + functions

Post by Chew Lek W » Tue, 17 Feb 2004 17:10:47

thanx again. i will try to learn up the things suggested and see which one
fits my requirement.





DCOM,
pointers.
impersonate
method.