Hi

I am developing a system to receive message using Skype API. I am able to get the string in WM_COPY message which shows like "MESSAGE 123 STATUS RECEIVED"

Now from this I extract the id i.e here say 123. And using this id i again send message using SendMessage() function. But it fails at one point. Here I have copied my little bit of code. Can anyone plz give me idea what is the problem or what should i do?

With thankx in advance.


My Code
=============================================

void SendCommand(char *command)
{
COPYDATASTRUCT oCopyData;

// send command to skype
oCopyData.dwData=0;
oCopyData.lpData=command;
oCopyData.cbData=strlen(command)+1;
if( oCopyData.cbData!=1 )
{
if(::SendMessage(HWND_BROADCAST, WM_COPYDATA, (WPARAM)hInit_MainWindowHandle, (LPARAM)&oCopyData)==FALSE )
{
hGlobal_SkypeAPIWindowHandle=NULL;
//printf("!!! Disconnectedn");
}
}
}


static LRESULT APIENTRY SkypeAPITest_Windows_WindowProc(
HWND hWindow, UINT uiMessage, WPARAM uiParam, LPARAM ulParam)
{
LRESULT lReturnCode;
bool fIssueDefProc;

char str[512]="";

lReturnCode=0;
int i;
fIssueDefProc=false;
switch(uiMessage)
{
case WM_POWERBROADCAST:
for (i=0;i<2;i++)
{
Sleep(100);
Beep(5000,1000);
}
::MessageBox(NULL,"Power broadcast",NULL,MB_OK);
DestroyWindow(hWindow);

break;
case WM_QUERYENDSESSION:
for (i=0;i<2;i++)
{
Sleep(100);
Beep(5000,1000);
}
::MessageBox(NULL,"QUERYENDSESSION",NULL,MB_OK);
DestroyWindow(hWindow);

//sprintf(s,"wParam:%d, lParam:%ld",wParam,lParam);
//::MessageBox(NULL,s,NULL,MB_OK);
break;

case WM_DESTROY:
hInit_MainWindowHandle=NULL;
PostQuitMessage(0);
break;
case WM_COPYDATA:
[b] if( hGlobal_SkypeAPIWindowHandle==(HWND)uiParam ) // It fails here when second time i use SendCommand() function {
COPYDATASTRUCT *oCopyData;
CWnd *callWindow;

//Code added by Mahesh Amarelia Credit to Bhagvat.
//Plz hu tamara haath jodu chhu. Aa code delete karo nahi.
PCOPYDATASTRUCT poCopyData=(PCOPYDATASTRUCT)ulParam;
sprintf(str,"%.*s",poCopyData->cbData,poCopyData->lpData);

iOriginalID = GetMessageID(str);

char sVar[512]="";
if(iOriginalID != 0)
{
sprintf(sVar,"GET MESSAGE %d BODY",iOriginalID);
SendCommand(sVar);
}


oCopyData = (COPYDATASTRUCT *)ulParam;
if (strstr((char *)oCopyData->lpData,"CALL") != 0)
{
callWindow = CWnd::FindWindow("TNotifForm",NULL);
if (callWindow)
{
callWindow->ShowWindow(SW_HIDE);
callWindow->ShowWindow(SW_SHOW);
callWindow->ShowWindow(SW_HIDE);
callWindow->ShowWindow(SW_SHOW);
}
}
lReturnCode=1;
}
break;
default:
if( uiMessage==uiGlobal_MsgID_SkypeControlAPIAttach )
{
switch(ulParam)
{
case SKYPECONTROLAPI_ATTACH_SUCCESS:
printf("!!! Connected; to terminate issue #disconnectn");
hGlobal_SkypeAPIWindowHandle=(HWND)uiParam;
break;
case SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION:
printf("!!! Pending authorizationn");
break;
case SKYPECONTROLAPI_ATTACH_REFUSED:
printf("!!! Connection refusedn");
break;
case SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE:
printf("!!! Skype API not availablen");
break;
case SKYPECONTROLAPI_ATTACH_API_AVAILABLE:
printf("!!! Try connect now (API available); issue #connectn");
break;
}
lReturnCode=1;
break;
}
fIssueDefProc=true;
break;
}
if( fIssueDefProc )
lReturnCode=DefWindowProc( hWindow, uiMessage, uiParam, ulParam);

return(lReturnCode);
}

Rest of the things are as normal. So assume that all the variables are declared correctly. And all the other functions are used properly.