-4

I've racked my brain over this for some hours: pClient is always NULL (0x000000). pClient doesn't seem to initialize the same way as ISkypePtr, IUserCollectionPtr, and IUserPtr?

ISkypePtr pSkype(__uuidof(Skype));
while (TRUE){
    IUserCollectionPtr pResults = pSkype->SearchForUsers("john doe");
    for (int i = 1; i <= pResults->Count; ++i){
        IUserPtr pUser = pResults->GetItem(i); _bstr_t handle = pUser->GetHandle(); 
        IClientPtr pClient;
        pClient->OpenAddContactDialog(handle);
        Sleep(30000);
    }
}
Sam Hosseini
  • 813
  • 2
  • 9
  • 17
Oloty
  • 15
  • 5

1 Answers1

-1

You're not making any effort to initialise pClient: in the other two cases you're giving it a CLSID to instantiate and you're assigning it from a COM object pointer you received back. I'd guess you want the following:

// Start client
IClientPtr pClient = pSkype->GetClient();
if (pClient->IsRunning == VARIANT_FALSE)
    pClient->Start(VARIANT_FALSE, VARIANT_FALSE);

(taken from this project on GoogleCode). This won't need to be in the while loop assuming you're not planning to close the client after each contact request.

But please use this responsibly and not for generating spam contact requests. Thanks.

Rup
  • 33,765
  • 9
  • 83
  • 112
  • Thanks, worked for me. I would say I don't know how I missed GetClient in the API docs, but I was up for 36+hrs when I posted that... – Oloty Oct 03 '14 at 11:29