Newsgroup: it.comp.lang.visual-basic
Titolo: [API] Ho trovato ICQ API

Guardate un po' cosa ho trovato sulla rete.
Le API di ICQ il famoso programma della "Net Generation"
Non ci ho capito una mazza, ma vi Invio integralmente il testo reperito.
Se. qualcuno volesse esprimere una opinione sarebbe interessante:
Ok People,    The attached code is the what I converted from the 'C' example
 in the
 ICQAPI Dev code...  It's what I use in my project "The ICQ Butler"...
 Regards,
 - Jay -
 Attribute VB_Name = "IcqApi"
 '
 ' Converted to Visual Basic By Jay L. Bray ICQ#104452
 ' Please leave my name in this code!
 ' And a small thanks in your program would be appreciated :-)...
 '
Const MaxIcqUsers = 250
Global p2p As Long
Global UserPointers(MaxIcqUsers) As Long ' Array to hold pointers
Global IcqUser As BSICQAPI_User
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Dest As Any,
Source As Any, ByVal cb As Long)
 ' ICQ API Calls
 '
 '*****************************************************************
 ' ICQAPINOTIFICATIONS.H
 '*****************************************************************
 Global Const ICQAPINOTIFY_ONLINELIST_CHANGE = 0
 Global Const ICQAPINOTIFY_ONLINE_FULLUSERDATA_CHANGE = 1
 Global Const ICQAPINOTIFY_APPBAR_STATE_CHANGE = 2
 Global Const ICQAPINOTIFY_ONLINE_PLACEMENT_CHANGE = 3
 Global Const ICQAPINOTIFY_OWNER_CHANGE = 4
 Global Const ICQAPINOTIFY_OWNER_FULLUSERDATA_CHANGE = 5
 Global Const ICQAPINOTIFY_ONLINELIST_HANDLE_CHANGE = 6
 Global Const ICQAPINOTIFY_FILE_RECEIVED = 8
 Global Const ICQAPINOTIFY_LAST = 80
 Global Const ICQAPINOTIFY_ONLINELISTCHANGE_ONOFF = 1
 Global Const ICQAPINOTIFY_ONLINELISTCHANGE_FLOAT = 2
 Global Const ICQAPINOTIFY_ONLINELISTCHANGE_POS = 3
 '*********************************************************
 ' ICQAPICALLS.H
 '*********************************************************
 Global Const BICQAPI_USER_STATE_ONLINE = 0
 Global Const BICQAPI_USER_STATE_CHAT = 1
 Global Const BICQAPI_USER_STATE_AWAY = 2
 Global Const BICQAPI_USER_STATE_OUT = 3
 Global Const BICQAPI_USER_STATE_OCCUPIED = 4
 Global Const BICQAPI_USER_STATE_DND = 5
 Global Const BICQAPI_USER_STATE_INVISIBLE = 6
 Global Const BICQAPI_USER_STATE_OFFLINE = 8
 '*********************************************************
 ' ICQAPIDATA.H
 '*********************************************************
 Type BSICQAPI_FireWallData
   m_bEnabled As Long
   m_bSocksEnabled As Long
   m_sSocksVersion As Long ' Short
   m_szSocksHost As String * 512
   m_iSocksPort As Long
   m_bSocksAuthenticationMethod As Long
 End Type
 Type BSICQAPI_User
   m_iUIN As Long
   m_hFloatWindow As Long 'hWnd
   m_iIP As Long
   m_szNickname As String * 20
   m_szFirstName As String * 20
   m_szLastName As String * 20
   m_szEmail As String * 100
   m_szCity As String * 100
   m_szState As String * 100
   m_iCountry As Long
   m_szCountryName As String * 100
   m_szHomePage As String * 100
   m_iAge As Long
   m_szPhone As String * 20
   m_bGender As Long 'String * 1
   m_iHomeZip As Long
   '// Version 1.0001
   m_iStateFlags As Long
 End Type
 Public BSICQAPI_User As BSICQAPI_User
 Type BSICQAPI_Group
   m_szName As String * 50
   m_iUserCount As Long
   m_ppUsers As BSICQAPI_User
 End Type
 Public BSICQAPI_Group As BSICQAPI_Group
 ' UTILITY FUNCTIONS
 'working...
 Declare Sub ICQAPIUtil_SetUserNotificationFunc Lib "icqmapi.dll" (ByVal
 uNotificationCode As Long, ByVal pUserFunc As Long)
 'working...
 Declare Sub ICQAPIUtil_FreeUser Lib "icqmapi.dll" (ByVal pUser As Long)
 'working...
 Declare Sub ICQAPIUtil_FreeUsers Lib "icqmapi.dll" (ByVal iCount As Long,
 ByVal pUsers As Long)
 'NOT CHECKED!!!
 Declare Sub ICQAPIUtil_FreeGroup Lib "icqmapi.dll" (ByVal pGroup As Long)
 ' CALLS
 'working...
 Declare Function ICQAPICall_SetLicenseKey Lib "icqmapi.dll" (ByVal pszName
 As String, ByVal pszPassword As String, ByVal pszLicense As String) As Long
 'working...
 Declare Function ICQAPICall_GetVersion Lib "icqmapi.dll" (ByRef lVersion As
 Long) As Long
 'working...
 Declare Function ICQAPICall_GetDockingState Lib "icqmapi.dll" (ByRef
 iDockingState As Long) As Long
 'NOT Sure!!!...
 Declare Function ICQAPICall_GetFirewallSettings Lib "icqmapi.dll" (ByRef
 oFireWallData As BSICQAPI_FireWallData) As Long
 'working...
 Declare Function ICQAPICall_GetFullOwnerData Lib "icqmapi.dll" (ByRef
ppUser
 As Long, ByVal lVersion As Long) As Long
 'working...
 Declare Function ICQAPICall_GetFullUserData Lib "icqmapi.dll" (ByRef pUser
 As BSICQAPI_User, ByVal lVersion As Long) As Long
 'working...
 Declare Function ICQAPICall_GetOnlineListDetails Lib "icqmapi.dll" (ByRef
 iCount As Long, ByRef ppUsers As Long) As Long
 'NOT Sure!!!...
 Declare Function ICQAPICall_GetOnlineListHandle Lib "icqmapi.dll" (ByRef
 hWindow As Long) As Long
 'working...
 Declare Function ICQAPICall_GetOnlineListPlacement Lib "icqmapi.dll" (ByRef
 iIsShowOnlineList As Long) As Long
 'NOT Sure!!!...
 Declare Function ICQAPICall_GetWindowHandle Lib "icqmapi.dll" (ByRef
hWindow
 As Long) As Long
 'working...
 Declare Function ICQAPICall_RegisterNotify Lib "icqmapi.dll" (ByVal
lVersion
 As Long, ByVal lCount As Long, ByVal piEvents As String) As Long
 'working...
 Declare Function ICQAPICall_UnRegisterNotify Lib "icqmapi.dll" () As Long
 'working...
 Declare Function ICQAPICall_SendFile Lib "icqmapi.dll" (ByVal iUIN As Long,
 ByVal pszFileNames As String) As Long
 '// Version 1.0001
 'working...
 Declare Function ICQAPICall_GetOnlineListType Lib "icqmapi.dll" (ByRef
 iListType As Integer) As Long
 'NOT Sure!!!...
 Declare Function ICQAPICall_GetGroupOnlineListDetails Lib "icqmapi.dll"
 (ByRef iGroupCount As Long, ByRef ppGroups As Long) As Long
 'working...
 Declare Function ICQAPICall_SetOwnerState Lib "icqmapi.dll" (ByVal iState
As
 Long) As Long
 'working...
 Declare Function ICQAPICall_SetOwnerPhoneState Lib "icqmapi.dll" (ByVal
 iPhoneState As Long) As Long
 'working...
 Declare Function ICQAPICall_SendMessage Lib "icqmapi.dll" (ByVal lUIN As
 Long, ByVal pszMessage As String) As Long
 'working...
 Declare Function ICQAPICall_SendURL Lib "icqmapi.dll" (ByVal lUIN As Long,
 ByVal pszMessage As String) As Long
 'working...
 Declare Function ICQAPICall_SendExternal Lib "icqmapi.dll" (ByVal lUIN As
 Long, ByVal pszExternal As String, ByVal pszMessage As String, ByVal
 bAutoSend As Long) As Long
 'NOT CHECKED!!!
 Declare Function ICQAPICall_Generic Lib "icqmapi.dll" (ByVal iCode As Long,
 ByVal pInBuffer, ByVal iInSize As Integer, ByVal ppOutBuffer, ByVal
iOutSize
 As Long) As Long
 '----------------------------------------------------------------------
 ' NOTIFICATIONS
 ' Sent when the online users list changes. A change can occur due to the
 following reasons:
 Public Sub ICQAPINotify_OnlineListChange(ByVal iType As Long)
   '
 End Sub
 'Sent when user's details where updated (e.g. when the owner pressed
update,
 in the info dialog).
 Public Sub ICQAPINotify_OnlineFullUserDataChange(ByVal lUIN As Long)
   '
 End Sub
 'Sent if the contact list docking status has changed
 Public Sub ICQAPINotify_AppBarStateChange(ByVal iDockingState As Long)
   '
 End Sub
 'Sent when the online tab is added/removed above the contact list (due to
 the user changing the preferences)
 Public Sub ICQAPINotify_OnlinePlacementChange()
   '
 End Sub
 'Sent when the current owner has changed.
 Public Sub ICQAPINotify_OwnerChange(ByVal lUIN As Long)
   '
 End Sub
 'Sent when the owner updates his own details.
 Public Sub ICQAPINotify_OwnerFullDataChange()
   '
 End Sub
 'Sent when the user switches between available contact lists (i.e. "Online"
 tab or "All" tab).
 Public Sub ICQAPINotify_OnlineListHandleChange(ByVal hWindow As Long)
   '
 End Sub
 'Sent when a file transfer event ended successfully. When multiple files
 were sent,
 'the notification will be sent after each received file.
 Public Sub ICQAPINotify_FileReceived(ByVal pszFileNames As String)
   '
 End Sub
 Function Start_Icq() As Long
   Dim sEvents As String * 9
   Dim Tmp As String
   Lrtn = ICQAPICall_SetLicenseKey("Your Company", "YourPassword",
 "YourLicKey")
   If Lrtn <> 0 Then
     Lrtn = ICQAPICall_GetVersion(lVersion)
     If Lrtn <> 0 Then
       InitIcq = True
       Init_Strings
     Else
       Start_Icq = 1
     End If
   Else
    Start_Icq = 2
   End If
   '-- Register the file notification:
   ICQAPIUtil_SetUserNotificationFunc ICQAPINOTIFY_ONLINELIST_CHANGE, _
     AddressOf ICQAPINotify_OnlineListChange
   ICQAPIUtil_SetUserNotificationFunc
 ICQAPINOTIFY_ONLINE_FULLUSERDATA_CHANGE, _
     AddressOf ICQAPINotify_OnlineFullUserDataChange
   ICQAPIUtil_SetUserNotificationFunc ICQAPINOTIFY_APPBAR_STATE_CHANGE, _
     AddressOf ICQAPINotify_AppBarStateChange
   ICQAPIUtil_SetUserNotificationFunc ICQAPINOTIFY_ONLINE_PLACEMENT_CHANGE,
_
     AddressOf ICQAPINotify_OnlinePlacementChange
   ICQAPIUtil_SetUserNotificationFunc ICQAPINOTIFY_OWNER_CHANGE, _
     AddressOf ICQAPINotify_OwnerChange
   ICQAPIUtil_SetUserNotificationFunc
ICQAPINOTIFY_OWNER_FULLUSERDATA_CHANGE, _
     AddressOf ICQAPINotify_OwnerFullDataChange
   ICQAPIUtil_SetUserNotificationFunc ICQAPINOTIFY_ONLINELIST_HANDLE_CHANGE,
_
     AddressOf ICQAPINotify_OnlineListHandleChange
   ICQAPIUtil_SetUserNotificationFunc ICQAPINOTIFY_FILE_RECEIVED, _
     AddressOf ICQAPINotify_FileReceived
   sEvents = Chr(ICQAPINOTIFY_ONLINELIST_CHANGE) & _
     Chr(ICQAPINOTIFY_ONLINE_FULLUSERDATA_CHANGE) & _
     Chr(ICQAPINOTIFY_APPBAR_STATE_CHANGE) & _
     Chr(ICQAPINOTIFY_ONLINE_PLACEMENT_CHANGE) & _
     Chr(ICQAPINOTIFY_OWNER_CHANGE) & _
     Chr(ICQAPINOTIFY_OWNER_FULLUSERDATA_CHANGE) & _
     Chr(ICQAPINOTIFY_ONLINELIST_HANDLE_CHANGE) & _
     Chr(ICQAPINOTIFY_FILE_RECEIVED)
   Lrtn = ICQAPICall_RegisterNotify(lVersion, 8, sEvents)
   If (Lrtn <> 1) Then
     Start_Icq = 3
   End If
 End Function
Function GetOnlineList() As Long
  Dim iCount as long, pPointer As Long, Lrtn as long
  Dim x As Integer
  Lrtn = ICQAPICall_GetOnlineListDetails(iCount, p2p)
  If iCount > 0 Then
    CopyMemory UserPointers(1), ByVal p2p, iCount * 4
    For x = 1 To iCount
      pPointer = UserPointers(x)
      CopyMemory IcqUser.m_iUIN, ByVal pPointer, Len(IcqUser)
      Lrtn = ICQAPICall_GetFullUserData(IcqUser, lVersion)
      ' After this call all you need to do is store the user's variables
into
      ' your own array type of the users information...
      ' Example:
      ' UserIDs.No(x).State = IcqUser.m_iStateFlags
      ' UserIDs.No(x).Gender = Int(IcqUser.m_bGender)
      ' UserIDs.No(x).Uin = IcqUser.m_iUIN
      ' UserIDs.No(x).Nick = IcqUser.m_szNickname
      ' UserIDs.No(x).IpAddress = IcqUser.m_iIP
    Next
 End If
  ICQAPIUtil_FreeUsers iCount, p2p ' free up ICQ's Memory
    GetOnlineList = iCount
End Function
--
Posted from 
romeo.logikos.it
 [193.70.26.1]
via Mailgate.ORG Server - 
http://www.mailgate.org

Interessa sempre tutto!
Si potrebbero sviluppare delle applicazioni che girano sotto "ICQ".
Io ho la documentazione ufficiale di queste API, scaricata dal sito di ICQ
www.mirabilis.com
Resto sintonizzato...
Fabrizio

 wrote in message
7spnfi$np5$1...@forst.ita.tip.net...


Potresti postare un esempio per l'utilizzi delle API di ICQ???


C'è un piccolo errore nell'esempio da te postato...
c'è il richiamo alla funzione Init_String che non esiste
a parte quello, credo che funzioni così...
si lancia il client di ICQ
dal programma VB si lanciano le uniche due Sub
Start_ICQ
GetOnLineList
da quest'ultima ricavo la lista degli utenti collegati ed il relativo IP
quando ho l'IP posso usare il controllo Winsock e fare quello che voglio
(a patto che l'altro utente sia in "ascolto" - per es. abbia un programma
server e tu il relativo client)
Sono tutte ipotesi, provo stasera (al lavoro non ho ICQ installato)
Il sito indicato da PAL purtroppo è un po' scarsino... non ci sono esempi
che cerchiamo noi.
A presto
Fabrizio
PS: per scaricare il DLL e la relativa documentazione (molto scarna) bisogna
registrarsi al sito
www.icq.com/api
 la registrazione è obbligatoria perché è richiesto un codice
segreto
nel listato infatti ci sono delle parole tipo "ditta" "username" "password",
quelle vengono comunicate dopo la registrazione.