Recent

Author Topic: Get contacts from phone  (Read 5282 times)

cristi2706

  • Newbie
  • Posts: 1
Get contacts from phone
« on: August 24, 2010, 01:01:19 pm »
Hello. I'm new to Lazarus. I have a question. I want to make an application, an online phone contacts backup tool, but I don't know how to read the contacts from the phone memory. I've found the code in C# (i think...) but I don't know how to convert it in Lazarus.
Quote
Add reference to Microsoft.WindowsMobile.PocketOutlook.dll  to your project.
using Microsoft.WindowsMobile.PocketOutlook;
//This code will bind contact list to a combobox.
OutlookSession poomSession = new OutlookSession();
this.contactsComboBox.DataSource = poomSession.Contacts.Items;
this.contactsComboBox.DisplayMember = "Contact";
this.contactsComboBox.ValueMember = "ID";
and
Quote
private string GetContactsName()
        {
            try
            {
                OutlookSession oSession = new OutlookSession();
                int iCounter = 0;
                string strName = null;
                if (oSession.Contacts.Items.Count > 0)
                {
                    while (iCounter < oSession.Contacts.Items.Count)
                    {
                        if (strName == null)
                        {
                            strName = oSession.Contacts.Items[iCounter].FirstName.ToString();
                        }
                        else
                        {
                            strName += "," + oSession.Contacts.Items[iCounter].FirstName.ToString();
                        }

                        iCounter++;

                    }

                }
                return strName;
            }
            catch
            {
                throw;
            }
        }

I've tried this:
Quote
uses DynLibs;
procedure getcontacts();
var OutlookSession:function():HRESULT; stdcall;
hDLL:   THandle;
oSession: HRESULT;
begin
   // Load Microsoft.WindowsMobile.PocketOutlook.dll library
    hDLL := LoadLibrary('Microsoft.WindowsMobile.PocketOutlook.dll');
    if hDLL < 32 then
    begin
       // Could not load RIL.DLL
       ShowMessage('Can''t load library!');
        Exit;
    end
    else
      begin
            oSession:=OutlookSession;  //DOESN'T WORK
            Label1.Caption:= 'Number of contacts: '+IntToStr(oSession.Contacts.Items.Count);   //DOESN'T WORK
      end;
FreeLibrary(hDLL);
end;
but it didn't worked.
Any ideea is apreciated.

 

TinyPortal © 2005-2018