当前位置导航:炫浪网>>网络学院>>编程开发>>C++教程>>C++进阶与实例

Skype API开发外壳程序基础学习

Skype是目前这个星球上最厉害的IM+VOIP软件,Skype现在已经改变了全球2.8亿人的生活方式。你,值得拥有! :)

Skype中文官网:http://skype.tom.com/

Skype全球官网:http://www.skype.com/

Skype也是世界上最开放,最具创新意识的IM工具,他提供了Skype API, Skype4COM, Skype4Java几种形式的开发接口给Skype爱好者编写Skype的交互程序或者Skype的插件。你可以使用任何你熟悉的语言,比如C/C++,VB, C#,Delphi,Java甚至PHP,VBScript。通过你的专业知识,去影响2.8亿的Skype用户。你也可以做到!:)

Skype全球开发者社区:http://developer.skype.com/

下面我们将展示一个最简单的访问Skype API的C++代码:

这里可以下载对应的VC6工程:http://wh.hust.colin.googlepages.com/SkypeInteractiveDemo.rar

//
// Copyright (c) 2004-2006, Skype Limited.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
//   * Redistributions of source code must retain the above copyright
//     notice, this list of conditions and the following disclaimer.
//   * Redistributions in binary form must reproduce the above
//     copyright notice, this list of conditions and the following
//     disclaimer in the documentation and/or other materials provided
//     with the distribution.
//   * Neither the name of the Skype Limited nor the names of its
//     contributors may be used to endorse or promote products derived
//     from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//

// tab size: 2

#include <windows.h>
#include <conio.h>
#include <stdio.h>
#include <string.h>[Page]
#include <process.h>
#include <rpcdce.h>

HWND hInit_MainWindowHandle;  ///<本程序创建的窗口的句柄
HINSTANCE hInit_ProcessHandle;  ///<本程序的进程句柄
char acInit_WindowClassName[128]; ///<本程序创建的窗口类名
HANDLE hGlobal_ThreadShutdownEvent; 
bool volatile fGlobal_ThreadRunning=true;

//Skype定义的消息ID,Skype通过向第三方程序发送这类消息来告知请求连接的结果
UINT uiGlobal_MsgID_SkypeControlAPIAttach;  

//Skype定义的消息ID,当第三方程序想获取Skype的交互时,
//必须通过广播(HWND_BROADCAST)发送这个消息,Skype收到后给用户弹出提示
//当用户允许后,交互关系就建立起来了。
UINT uiGlobal_MsgID_SkypeControlAPIDiscover;

//Skype的窗口句柄
HWND hGlobal_SkypeAPIWindowHandle=NULL;

//BOOL变量标识是否打印更详细的消息内容
#if defined(_DEBUG)
bool volatile fGlobal_DumpWindowsMessages=true;
#else
bool volatile fGlobal_DumpWindowsMessages=false;
#endif
DWORD ulGlobal_PromptConsoleMode=0;
HANDLE volatile hGlobal_PromptConsoleHandle=NULL;

enum {
//第三方程序连接成功,在wParam中可以获取到Skype的API窗口句柄
 SKYPECONTROLAPI_ATTACH_SUCCESS=0,     
//Skype已经收到连接请求了,并给用户弹出了第三方程序请求访问Skype的提示
//这时候连接并没有成功建立,必须等到SKYPECONTROLAPI_ATTACH_SUCCESS消息才行  
  SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION=1, 
//Skype用户拒绝了第三方程序的访问请求
  SKYPECONTROLAPI_ATTACH_REFUSED=2,      
//API接口当前不可使用。这种情况有时候发生,比如当前Skype没有任何用户登录进去。  
//第三方程序必须等到Skype广播了SKYPECONTROLAPI_ATTACH_API_AVAILABLE消息时再去尝试连接才有效
  SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE=3,     
  SKYPECONTROLAPI_ATTACH_API_AVAILABLE=0x8001
};

//从标准输入窗口中获取一行输入到pacPromptBuffer中
bool Global_Console_ReadRow( char *pacPromptBuffer, unsigned int uiMaxLength)
{
 HANDLE hConsoleHandle, hDuplicatedConsoleHandle;
 DWORD ulCharactersRead, ulConsoleMode;
 unsigned int uiNewLength;

共4页 首页 上一页 1 2 3 4 下一页 尾页 跳转到
相关内容
赞助商链接