Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Hanging Up calls in C# Compact Framework

251 views
Skip to first unread message

Euan Ritchie

unread,
Jan 20, 2008, 2:00:14 AM1/20/08
to
I've written an application to hang up calls when closing a slide phone
and I do it by issuing an End Key press. It works fine. But I've been
asked to do it another way so as not to invoke the various behaviours an
End Key does.

So I've done some research on how to end a call and I've found a number
of TAPI wrappers for C#, but they all seem to assumme the application
using them will be initiating the call to end.

I think I can hang up a call if only I can get a handle to it in the
first place and the only code I've seen to do that is in C++ that has
two problems for me - I don't know how to convert it to C# (the pointer
manipulation in it is complex and I don't know how to convert the code
for C# structures) and secondly it's just too big to be reasonable for
such a simple task.

So I'm asking, can anyone show me either an easy way to hang up calls
(not intiated by my application) in C#, or just how to get a handle to
any current voice call please?

I was wondering if phone.exe has a command line option that could be
invoked to do the job?

Grant Schenck

unread,
Jan 20, 2008, 10:28:00 AM1/20/08
to
Normally you would learn about calls you DIDN'T make by watching events from
your TAPI connection in the call back you specified when you initialize the
connection to TAPI. In this event you will get LINE_APPNEWCALL and
LINE_CALLSTATE events which contain as one of their parameters the call ID
of the call. Have you figured out how to get events from TAPI and extract a
call ID?
--
Grant Schenck

"Euan Ritchie" <eu...@ionwerks.co.nz> wrote in message
news:4792f192$1...@clear.net.nz...

Euan Ritchie

unread,
Jan 20, 2008, 2:58:27 PM1/20/08
to
Grant Schenck wrote:

> Normally you would learn about calls you DIDN'T make by watching events from
> your TAPI connection in the call back you specified when you initialize the
> connection to TAPI. In this event you will get LINE_APPNEWCALL and
> LINE_CALLSTATE events which contain as one of their parameters the call ID
> of the call. Have you figured out how to get events from TAPI and extract a
> call ID?

No, I've been hoping not to need to (it seems silly to me for an
application to need to do so much work for such a simple task, but
perhaps I'm not considering the unique needs of a phone adequately).

I've been chasing tantilising hints that what I want is possible, such
as the HangUpCall function described here:
http://www.msdner.com/dev-archive/152/11-36-1521241.shtm

Currently I'm considering creating a C++ DLL that does just that single
thing and invoking it to solve my problem.

I really don't want to have to worry about hooked callbacks and the like
in my as currently very simple application. It would raise it to a new
level of complexity and worry about state management that it doesn't
need right now.

Grant Schenck

unread,
Jan 20, 2008, 4:03:14 PM1/20/08
to
The only way to know about calls that you don't create is via events. While
you might be able to call lineGetNewCalls (like the code you linked to does)
after you open the line, this will only tell you about calls which were
known to TAPI. If you are the first application running on the machine then
TAPI won't know about any active calls so the service provider should
generate call state events for calls in progress so again, you need to
handle events to learn about these calls too.
--
Grant Schenck

"Euan Ritchie" <eu...@ionwerks.co.nz> wrote in message

news:4793a7f8$1...@clear.net.nz...

Euan Ritchie

unread,
Jan 20, 2008, 5:38:29 PM1/20/08
to
Grant Schenck wrote:

> The only way to know about calls that you don't create is via events. While
> you might be able to call lineGetNewCalls (like the code you linked to does)
> after you open the line, this will only tell you about calls which were
> known to TAPI. If you are the first application running on the machine then
> TAPI won't know about any active calls so the service provider should
> generate call state events for calls in progress so again, you need to
> handle events to learn about these calls too.

Checking that I uderstand you:

Any application (such as mine) needs to initialize TAPI to use it. It
can then only know about events from that initialization onwards. So if
a call was connected before TAPI initilization in this (my) app it won't
know about the exisitng call to be able to do anything to (such as drop) it?

So I need my app running first, monitoring calls, noting when any start,
so that when later I need to drop it I have the handle?

If this is true it seems to me someone would be doing people like me a
favour to write a service that does nothing but monitor calls and expose
an interface to manipulate them - so that applications don't need to
monitor calls themselves to maniputlate them. Seems so obvious surely
someone has done it?

Euan Ritchie

unread,
Jan 20, 2008, 6:39:02 PM1/20/08
to

> So I need my app running first, monitoring calls, noting when any start,
> so that when later I need to drop it I have the handle?

Assumming I have this correct, I imagine a lot of people ask for an
example to start them off on doing this. I've gone through a bunch of
TAPI code and get the general idea, but as I want to work in C# CF2 it's
a bit problematic.

Lots of people recommend wrappers and I've looked at Alex Feinmans. I've
even had a go at using it (unsuccessful, I think I mangled it somewhat
trying to update it to CF2, but i'm not sure. His CF2 version doesn't
seem to be available anymore). And as for the recommendations to use
OpenNetCFs $600 wrapper!

It'd be nice to have a known working example of using TAPI in C# and CF2
to crib from. Anybody have a link handy to such a thing?

Grant Schenck

unread,
Jan 21, 2008, 1:02:19 PM1/21/08
to
The best proactive is to call lineGetNewCalls when you open a line and also
expect that you may get APP_NEWCALLS events as well as CALLSTATE events
after you open the line including, potentially call state events for events
that you normally wouldn't expect as the initial call state of a call (such
as CONNECTED.)

Well, that service is called TAPI. It is a bit complex but at the end of
the day, any wrapper to be as powerful as raw TAPI would need to be
similarly complex.

The real solution is for MS to get with the program and support TAPI. The
fact that they keep it in each version of the OS but don't update the
development interface to .NET indicates a severe disconnect in terms of
strategy.

The sad fact is that at some level MS doesn't understand what TAPI is used
for and keeps trying to foist off OCS/RTC as some kind of equivalent (which
is isn't.) Show me how to write anything close to the kind of applications
I routinely develop with TAPI using the OCS native interfaces and I'm
prepared to eat my hat. Until that day, TAPI is a necessary evil.
--
Grant Schenck

"Euan Ritchie" <eu...@ionwerks.co.nz> wrote in message

news:4793cd7b$1...@clear.net.nz...

Matthias Moetje [MVP]

unread,
Jan 21, 2008, 5:58:10 PM1/21/08
to
Euan,

IMO what you are currently doing (simulating key press
of the end call button) is the best you can do.

With the methods described on the thread you will
be able to get information about the calls but you will
not be able to end a call the phone.exe already OWNS.
There can be only a single owner of a call and as long
as you app doesn't get owner prvileges you can't end
a call anyway. Only the application itself can end its
own calls.

Best regards,

Matthias Moetje
-------------------------------------
TAPI WIKI: http://www.tapi.info
-------------------------------------
TERASENS GmbH
Augustenstraße 24
80333 Munich, GERMANY
-------------------------------------
e-mail: moetje at terasens dot com
www: www.terasens.com
-------------------------------------


"Euan Ritchie" <eu...@ionwerks.co.nz> wrote in message

news:4792f192$1...@clear.net.nz...

Grant Schenck

unread,
Jan 22, 2008, 6:26:24 PM1/22/08
to
Maybe I'm misunderstanding what you are saying but lineSetCallPrivilege
allows any app to assert ownership of a call even if they only have a
monitor handle.
--
Grant Schenck

"Matthias Moetje [MVP]" <moetje@terasens_nospam_.de> wrote in message
news:%23AoyZEI...@TK2MSFTNGP04.phx.gbl...

Andreas Marschall [MVP TAPI]

unread,
Jan 22, 2008, 8:25:26 PM1/22/08
to
Grant,
you are right.

Matthias,
you are wrong regarding the single ownership of a call.
With TAPI2 there can be be multiple onwerns of the same call by means of
lineSetCallPrivilege(_ONWER).
You can simply try this with multiple instances of TB230.
All apps that have owner privilege on a call can concurrently lineDrop() it.

--
Best Regards
Andreas Marschall
Microsoft MVP for TAPI / Windows SDK
TAPI / TSP Developer and Tester
My TAPI and TSPI FAQ:
http://www.I-B-A-M.de/Andreas_Marschall's_TAPI_and_TSPI_FAQ.htm
My Toto® Tools (a collection of free, mostly TAPI related tools):
http://www.i-b-a-m.de/Andreas_Marschall's_Toto_Tools.htm
TAPI development around the world (Frappr! map):
http://www.frappr.com/TAPIaroundTheWorld
* Please post all messages and replies to the newsgroup so all may
* benefit from the discussion. Private mail is usually not replied to.
* This posting is provided "AS IS" with no warranties, and confers no rights.


"Grant Schenck" <sche...@optonline.net> schrieb im Newsbeitrag
news:OTCcw4UX...@TK2MSFTNGP04.phx.gbl...


> Maybe I'm misunderstanding what you are saying but lineSetCallPrivilege
> allows any app to assert ownership of a call even if they only have a
> monitor handle.

> "Matthias Moetje [MVP]" <moetje@terasens_nospam_.de> wrote in message
> news:%23AoyZEI...@TK2MSFTNGP04.phx.gbl...

Matthias Moetje [MVP]

unread,
Jan 23, 2008, 1:28:15 PM1/23/08
to
Grant,

of course you are right. I forgot about that. I was just too much
into TAPI3 thinking where this is not possible...

Matthias Moetje [MVP]

unread,
Jan 23, 2008, 1:30:40 PM1/23/08
to
Andreas,

thanks for the correction. Of course you are right. This feature
is missing in TAPI3 and I just forgot that TAPI2.x allows
this.

Best regards,

Matthias Moetje
-------------------------------------
TAPI WIKI: http://www.tapi.info
-------------------------------------
TERASENS GmbH
Augustenstraße 24
80333 Munich, GERMANY
-------------------------------------
e-mail: moetje at terasens dot com
www: www.terasens.com
-------------------------------------

"Andreas Marschall [MVP TAPI]" <Andreas....@I-B-A-M.de> wrote in
message news:eRVAe7VX...@TK2MSFTNGP02.phx.gbl...

Grant Schenck

unread,
Jan 23, 2008, 6:58:48 PM1/23/08
to
Good to know. Aside from poking with 3.x a few years ago I'm strictly a 2.x
man!

I must say that the reality is that at least for client apps, the idea
multiple apps running in monitor mode and grabbing ownership when they want
to control the call is a reality. If 3.x doesn't allow this then that is
another strike against it.

Regards,
--
Grant Schenck

"Matthias Moetje [MVP]" <moetje@terasens_nospam_.de> wrote in message

news:OFrs52eX...@TK2MSFTNGP05.phx.gbl...

0 new messages