LISTING 1

Integer wf_connect()
//ret val
Long ll_RetVal

///register our messages with windows\
iu_SkypeAttatchMsg   = RegisterWindowMessage("SkypeControlAPIAttach");
iu_SkypeDiscoverMsg = RegisterWindowMessage("SkypeControlAPIDiscover");

//send broadcast message to find Skype
ll_Retval = SendMessage(WM_BROADCAST_MSG, iu_SkypeDiscoverMsg, Handle(This), 0)
If ll_RetVal = 0 Then
/MessageBox(is_modulename, 'Skype API is not available: ' + String(ll_RetVal))
	Return -1
End If

//here...success
Return 1


LISTING 2

Event other()

If Message.Number = iu_SkypeAttatchMsg Then
Choose Case lparam
Case 0
	//MessageBox(is_ModuleName, 'SKYPECONTROLAPI_ATTACH_SUCCESS = 0: Client is successfully
	 attached and API window handle can be found in wParam parameter;')
	ib_connected = True
	il_SkypeHandle = Message.wordparm

	Case 1
	MessageBox(is_Modulename, 'SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION = 1: Skype has
	 acknowledged connection request and is waiting for confirmation from the user. The client
	  is not yet attached and should wait for SKYPECONTROLAPI_ATTACH_SUCCESS message;')
	  ib_connected = False

	Case 2
	MessageBox(is_Modulename, 'SKYPECONTROLAPI_ATTACH_REFUSED = 2: User has explicitly denied
	 access to client;')
	 ib_connected = False

	Case 3
	MessageBox(is_modulename, 'SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE = 3: API is not available
	 at the moment. For example, this happens when no user is currently logged in. Client
	  should wait forSKYPECONTROLAPI_ATTACH_API_AVAILABLE broadcast before making any further
	   connection attempts.')
	   ib_connected = False
Case 4


End Choose
Return 0
ElseIf Message.Number = WM_COPY_DATA_MSG And Message.wordparm = il_Skypehandle Then
RTLMoveMemory( REF istr_copydata, Message.LongParm, 12 )
is_RetData = STRING(istr_copydata.pData, "address")
//MessageBox(is_modulename, is_retdata)
This.Postevent('ue_process_inbound')
End If

Return 0

LISTING 3

Integer wf_send_command(string as_cmd)

//cmd buffer
String ls_Buffer

//copy data struct
x_copydata lstr_copydata

//ret val
Long ll_RetVal

//need ptr to string
Long ll_stringpointer

// get some memory
ls_Buffer = Space(5000)

//pass in our arg
ls_Buffer = as_cmd

//trick for getting ptr to string
ll_StringPointer = LocalAlloc( 0, Len( ls_Buffer))
lStrCpy( ll_StringPointer, ls_Buffer )

//populate our "send" buffer
lstr_copydata.dwData = 0
lstr_copydata.cbdata = Len(ls_Buffer) + 1
lstr_copydata.pData = ll_StringPointer

//use API messaging call to "talk to" Skype
ll_RetVal = SendMessageA(il_SkypeHandle, WM_COPY_DATA_MSG, Handle(This),  lstr_copydata)

//cleanup
LocalFree( ll_StringPointer )

If ll_RetVal = 0 Then
//MessageBox(is_modulename, 'Skype API is not available: ' + String(ll_RetVal))
	Return -1
End If

//here...success
Return ll_RetVal
\