Help - Search - Members - Calendar
Full Version: Why I receive WM_COPYDATA return 1 will disconnect?
Skype Community > English > Development, Betas and Skype Garage > Skype Public API
Falldog
Why I receive a message WM_COPYDATA
and I return true(1)
Skype will disconnect???
TheUberOverlord
QUOTE(Falldog @ Mon Sep 10 2007, 05:49) [snapback]439641[/snapback]

Why I receive a message WM_COPYDATA
and I return true(1)
Skype will disconnect???


Because it is not the right response. Here is an example:


http://forum.skype.com/index.php?showtopic=54549
Falldog
I had read the post.
But I still can't understand.

I send the command to Skype.
And Skype response message to me. I got the WM_COPYDATA. Should I do anything with this response to Skype?

I write in BCB.
this code will work.
CODE

void __fastcall TForm1::WndProc( TMessage & msg ){
      if( msg.Msg==WM_COPYDATA ){
             if( hGlobal_SkypeAPIWindowHandle==(HWND)msg.WParam ){
                     //...
                     MessageBox(this->Handle, (PCOPYDATASTRUCT)msg.LParam->lpData, message, MB_OK | MB_ICONINFORMATION);
             }
             return 1;
      }
}


this code will not work.
Skype will disconnect!
CODE

void __fastcall TForm1::WndProc( TMessage & msg ){
      if( msg.Msg==WM_COPYDATA ){
             if( hGlobal_SkypeAPIWindowHandle==(HWND)msg.WParam ){
                     //...
                     //MessageBox(this->Handle, (PCOPYDATASTRUCT)msg.LParam->lpData, message, MB_OK | MB_ICONINFORMATION);
             }
             return 1;
      }
}


I can't understand. Why????
TheUberOverlord
QUOTE(Falldog @ Mon Sep 10 2007, 07:28) [snapback]439693[/snapback]

I had read the post.
But I still can't understand.

I send the command to Skype.
And Skype response message to me. I got the WM_COPYDATA. Should I do anything with this response to Skype?

I write in BCB.
this code will work.
CODE

void __fastcall TForm1::WndProc( TMessage & msg ){
      if( msg.Msg==WM_COPYDATA ){
             if( hGlobal_SkypeAPIWindowHandle==(HWND)msg.WParam ){
                     //...
                     MessageBox(this->Handle, (PCOPYDATASTRUCT)msg.LParam->lpData, message, MB_OK | MB_ICONINFORMATION);
             }
             return 1;
      }
}


this code will not work.
Skype will disconnect!
CODE

void __fastcall TForm1::WndProc( TMessage & msg ){
      if( msg.Msg==WM_COPYDATA ){
             if( hGlobal_SkypeAPIWindowHandle==(HWND)msg.WParam ){
                     //...
                     //MessageBox(this->Handle, (PCOPYDATASTRUCT)msg.LParam->lpData, message, MB_OK | MB_ICONINFORMATION);
             }
             return 1;
      }
}


I can't understand. Why????


Quote: "If the API client spends more than 1 second processing a message, the connection is disconnected. Use the PING command to test the connection status. To ease debugging during development, in regedit enter the key APITimeoutDisabled (DWORD value, 0 = timeout enabled 1 = timeout disabled) into the HKCU\Software\Skype\Phone\UI file in the registry to override the 1 second timeout."

From: https://developer.skype.com/Docs/ApiDoc/Skype_API_on_Windows

The messagebox prompt is causing a timeout.
awahlig
QUOTE(Falldog @ Mon Sep 10 2007, 13:28) [snapback]439693[/snapback]

I had read the post.
But I still can't understand.

I send the command to Skype.
And Skype response message to me. I got the WM_COPYDATA. Should I do anything with this response to Skype?

I write in BCB.
this code will work.
CODE

void __fastcall TForm1::WndProc( TMessage & msg ){
      if( msg.Msg==WM_COPYDATA ){
             if( hGlobal_SkypeAPIWindowHandle==(HWND)msg.WParam ){
                     //...
                     MessageBox(this->Handle, (PCOPYDATASTRUCT)msg.LParam->lpData, message, MB_OK | MB_ICONINFORMATION);
             }
             return 1;
      }
}


this code will not work.
Skype will disconnect!
CODE

void __fastcall TForm1::WndProc( TMessage & msg ){
      if( msg.Msg==WM_COPYDATA ){
             if( hGlobal_SkypeAPIWindowHandle==(HWND)msg.WParam ){
                     //...
                     //MessageBox(this->Handle, (PCOPYDATASTRUCT)msg.LParam->lpData, message, MB_OK | MB_ICONINFORMATION);
             }
             return 1;
      }
}


I can't understand. Why????

First of all, look at your code, you're using "return 1" in a function that has "void" as its return type. That's obviously wrong.

However, the real reason why it doesn't work for you is that you're not suppose to use "return" here (the "void" is ok). Use this instead:
CODE
msg.Result = 1;

This was discussed not long ago in this thread:
http://forum.skype.com/index.php?showtopic=95554
TheUberOverlord
QUOTE(awahlig @ Mon Sep 10 2007, 13:53) [snapback]439897[/snapback]

First of all, look at your code, you're using "return 1" in a function that has "void" as its return type. That's obviously wrong.

However, the real reason why it doesn't work for you is that you're not suppose to use "return" here (the "void" is ok). Use this instead:
CODE
msg.Result = 1;

This was discussed not long ago in this thread:
http://forum.skype.com/index.php?showtopic=95554


Well, it is also important to note that with the messagebox prompt, no matter what the value is, a timeout would be created using the default timeout, unless of course you answered the messagebox prompt in less that a second, with the current example code.
Falldog
QUOTE(awahlig @ Mon Sep 10 2007, 19:53) [snapback]439897[/snapback]

First of all, look at your code, you're using "return 1" in a function that has "void" as its return type. That's obviously wrong.

However, the real reason why it doesn't work for you is that you're not suppose to use "return" here (the "void" is ok). Use this instead:
CODE
msg.Result = 1;

This was discussed not long ago in this thread:
http://forum.skype.com/index.php?showtopic=95554


Sorry, it's my wrong with the post.
In my code, it's writed in msg.Result =1;, not return 1;
And, it still dosen't work. without the MessageBox(...);

QUOTE(TheUberOverlord @ Mon Sep 10 2007, 20:01) [snapback]439903[/snapback]

Well, it is also important to note that with the messagebox prompt, no matter what the value is, a timeout would be created using the default timeout, unless of course you answered the messagebox prompt in less that a second, with the current example code.


So... you mean the MessageBox() answer the Skype response.
If I don't call the MessageBox() , it would timeout. And Skype will disconnect?
awahlig
QUOTE(Falldog @ Tue Sep 11 2007, 06:05) [snapback]440042[/snapback]

Sorry, it's my wrong with the post.
In my code, it's writed in msg.Result =1;, not return 1;
And, it still dosen't work. without the MessageBox(...);
So... you mean the MessageBox() answer the Skype response.
If I don't call the MessageBox() , it would timeout. And Skype will disconnect?

Lets get it straight.

There are two things you have to do with WM_COPYDATA to keep attached to Skype.
1. Return non-zero value in msg.Result.
2. Return from the WndProc() function in less than about a second.

If you still won't be able to get it working, show us the whole code.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.