phone call record in ppc

  • Thread starter Thread starter brprathima
  • Start date Start date
B

brprathima

i would like to know how to record an incoming phone call and transfer
it into my pocket pc database.iam using vs 2005 and sql server
2005.Active sync for synchronization.can anyone help plz time short.
thanks
 
If you want to record the call as it comes in, then you can use the
SystemState class:

In your constructor:

Microsoft.WindowsMobile.Status.SystemState state = new
Microsoft.WindowsMobile.Status.SystemState(Microsoft.WindowsMobile.Status.SystemProperty.PhoneIncomingCallerNumber);
state.Changed += new
Microsoft.WindowsMobile.Status.ChangeEventHandler(state_Changed);

Then use the class to get the phone number:

void state_Changed(object sender,
Microsoft.WindowsMobile.Status.ChangeEventArgs args)
{
string phoneNumber = (string)args.NewValue;

MessageBox.Show(phoneNumber);
}

This will give you the caller id phone number.

You can also use the call log API's to retrieve the call log:

Here are the dll imports needed:

[StructLayout(LayoutKind.Sequential)]
public struct CALLLOGENTRY
{
public UInt32 cbSize;
public UInt64 ftStartTime;
public UInt64 ftEndTime;
public short iom;
public bool fOutgoing;
public bool fConnected;
public bool fEnded;
public bool fRoam;
public short cidt;
public IntPtr pszNumber;
public IntPtr pszName;
public IntPtr pszNameType;
public IntPtr pszNote;
};

[DllImport("phone.dll", EntryPoint = "PhoneOpenCallLog", SetLastError = true)]
private static extern int PhoneOpenCallLog(ref IntPtr pHandle);

[DllImport("phone.dll", EntryPoint = "PhoneCloseCallLog",
SetLastError = true)]
private static extern int PhoneCloseCallLog(IntPtr pHandle);

[DllImport("phone.dll", EntryPoint = "PhoneGetCallLogEntry",
SetLastError = true)]
private static extern int PhoneGetCallLogEntry(IntPtr pHandke, ref
CALLLOGENTRY pEntry);

You can then get the call log entries using the following:

private void menuItem6_Click(object sender, EventArgs e)
{
IntPtr handle = IntPtr.Zero;
CALLLOGENTRY entry = new CALLLOGENTRY();

PhoneOpenCallLog(ref handle);

entry.cbSize = (uint)Marshal.SizeOf(entry);

if (handle != IntPtr.Zero)
{
listView.Items.Clear();
listView.Columns[0].Width = this.Width;

while (PhoneGetCallLogEntry(handle, ref entry) == 0)
{

string phoneNumber =
Marshal.PtrToStringUni(entry.pszNumber);
string name = Marshal.PtrToStringUni(entry.pszName);
if (name == null)
{
name = string.Empty;
}

ListViewItem item = new ListViewItem(string.Format("{0}
{1}", phoneNumber, name));

listView.Items.Add(item);
}

PhoneCloseCallLog(handle);
}
else
{
int error = Marshal.GetLastWin32Error();
}
}
I hope this helps.

Rick D.
Contractor
 
Back
Top