The correct way to detect the caller ID is to use the TAPI API.
You can find a C# TAPI library (called ITAPI3) here.
http://www.julmar.com/tapi/
Check the April 04, 2006 blog entry for some notes on building programs linked against it on 64-bit Windows.
And here's sample code:
TTAPI tapi = new TTAPI();
tapi.TE_CALLINFOCHANGE += (sender, e) =>
{
if (e.Cause == CALLINFOCHANGE_CAUSE.CIC_CALLERID)
{
Console.WriteLine(e.Call.get_CallInfo(CALLINFO_STRING.CIS_CALLERIDNUMBER));
Console.WriteLine(e.Call.get_CallInfo(CALLINFO_STRING.CIS_CALLERIDNAME));
}
}
tapi.Initialize();
// ...
// Keep the TAPI object in memory so it can listen for events
// ...
tapi.ShutDown();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…