Create a new contact and then try to write it to the phone. But there is an error.The coding as follow:

IPhonebook *pIPhonebook;
IContact *pIContact;
PhonebookMemory pIMem;
IUnknown *pIUnknown;
......
pIContact = pIPhonebook->CreateContact();
pIContact->PutName( (BSTR)"TEST" ); -->Here an error is raised.

There is a same error in under coding:
pIPhonebook->GetMemoryInUse( &pIMem);
pIContact = pIPhonebook->GetContact( pIMem,1 );
long lID = pIContact->GetGroupID(); -->Here an error is raised.

Why?How can I initial the "pIContact"?
Thanks!