From: Per on
Hi,

I am desperately trying to make make my PPC phone switch to speaker during a
call so you don't have to hold it up to your ear, but so far without any
luck. I have tried using the phoneSetHookSwitch but I get a
PHONEERR_OPERATIONFAILED. Here is my code (in c#):

int dwApiVersion = 0x20000;
int m_dwNumDev = 0;
PHONEINITIALIZEEXPARAMS initParams = new
PHONEINITIALIZEEXPARAMS(IntPtr.Zero);

IntPtr hPhoneApp = IntPtr.Zero;

// Intialize TAPI app and throw an exception if failed
int ret = NativeTapi.phoneInitializeEx(out hPhoneApp, IntPtr.Zero,
IntPtr.Zero, "MyApp", out m_dwNumDev, ref dwApiVersion, initParams);
if ( ret != 0 )
throw new TapiException("phoneInitializeEx failed!", ret);

IntPtr hPhone;
ret = NativeTapi.phoneOpen(hPhoneApp, 0, out hPhone, dwApiVersion, 0,
IntPtr.Zero, 2);
if ( ret != 0 )
throw new TapiException("phoneOpen failed!", ret);

ret = NativeTapi.phoneSetHookSwitch(hPhone, 2, 8);

if ( ret < 0 )
throw new TapiException("phoneSetHookSwitch failed!", ret);

System.Threading.Thread.Sleep(500);

ret = NativeTapi.phoneClose(hPhone);
if ( ret != 0 )
throw new TapiException("phoneClose failed!", ret);

ret = NativeTapi.phoneShutdown(hPhoneApp);
if ( ret != 0 )
throw new TapiException("phoneShutdown failed!", ret);


Can anybody tell me what is going wrong? Is this even the right way to go
about it? From what I have been able to gather from google I am not sure
this is even possible on PPC. Is there any other way? How does Windows
Mobile do it?

Thanks in advance,

Per Rasmussen.