News:

MyKidsDiary.in :: Capture your kids magical moment and create your Online Private Diary for your kids

Main Menu

Making a Phone Call in VB.NET

Started by thiruvasagamani, May 23, 2009, 07:40 PM

Previous topic - Next topic

thiruvasagamani

Making a Phone Call in VB.NET

Our code for MakeCall in VB.NET ports with few major modifications from the C# code detailed above. We use IntPtr variables to hold value for most of our functionality. One difference is that in the forward declaration of MakeCall, we specify that the PhoneMakeCallInfo structure instance will be passed in as a reference.
Copy Code

    <System.Runtime.InteropServices.DllImport("phone.dll")> _
    Private Shared Function PhoneMakeCall(ByRef ppmci As
      PhoneMakeCallInfo) As IntPtr
    End Function


We process the PhoneMakeCallInfo structure almost identically to as before. We break the PhoneNumber string into a character array then write to memory using iPhoneNumber as a memory alignment pointer.
Copy Code

PhoneNumber.Insert(PhoneNumber.Length, " ")
Dim cPhoneNumber() As Char = PhoneNumber.ToCharArray()
Dim pAddr() As Char = cPhoneNumber

Dim info As PhoneMakeCallInfo = New PhoneMakeCallInfo
info.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(info)
Dim iPhoneNumber As IntPtr = Marshal.AllocHLocal(cPhoneNumber.Length)
        System.Runtime.InteropServices.Marshal.Copy(cPhoneNumber, 0,
          iPhoneNumber, cPhoneNumber.Length)
info.pszDestAddress = iPhoneNumber


After we point the pszDestAddress member to this memory space and set the confirm before dial option, we pass the structure instance into PhoneMakeCall.
Copy Code

If PromptBeforeCall Then
   info.dwFlags = PMCF_PROMPTBEFORECALLING
Else
   info.dwFlags = PMCF_DEFAULT
End If
   res = PhoneMakeCall(info)


Source : MSDN
Thiruvasakamani Karnan