Visualizzazione dei risultati da 1 a 7 su 7

Discussione: [API] Send Message

  1. #1

    [API] Send Message

    la domanda è semplice: come posso far parlare 2 applicazioni?

    so che esiste la funzione SendMessage ma mi manca il corrispondente per ricevere, qualcuno mi sa aiutare??

    Grazie, Pietro

  2. #2
    Utente di HTML.it
    Registrato dal
    Mar 2006
    Messaggi
    4
    devi usare un HOOK!!!

  3. #3
    mmm....ok, adesso guardo nell'msdn...

    grazie mille :sgrat:

  4. #4
    domanda: perchè hai o ti è stata chiusa la discussione su "Programmazione"? le API non sono un argomento strettamente attinente a VB e VB.net!!!

    Ad ogni modo, l'API SendMessage può servire in ambiente Windows per mandare dei messaggi ad una finestra, ma messaggi di Windows (timer,chiusura,notificazioni varie).
    Non hai bisogno di creare qualcosa che riceva questi messaggi, perchè essi vengono direttamente "sentiti" dalla finestra a cui tu li hai spediti (attraverso un processo in background presente per ogni finestra che si chiama Window Procedure).

    Ti basta per ogni applicazione creare un metodo On... dove ... sta per l'evento di Windows che hai richiamato (ad es. OnTimer), lo puoi creare automaticamente co VS col ClassWizard.

    QUINDI IN REALTA' PER FAR PARLARE DUE APPLICAZIONI PUOI ANCHE USARE LA SEND MESSAGE, MA ENTRAMBE DEVONO POSSEDERE UNA FINESTRA (O UNA DIALOG) che li riceva.

    Altrimenti ci sono altri modi più classici per farle comunicare ad esempio con un HOOK o con delle PIPE.

    Ciao

  5. #5
    ti ringrazio, anch'io pensavo che le api potessero essere di interesse più generale, ma il moderatore ha sentenziato così... :master:

    cmq qualche esempio o informazioni le trovo sull'msdn??

  6. #6
    si certo. Dall'msdn:

    The SendMessage function sends the specified message to a window or windows. The function calls the window procedure for the specified window and does not return until the window procedure has processed the message. The PostMessage function, in contrast, posts a message to a thread's message queue and returns immediately.

    LRESULT SendMessage(
    HWND hWnd, // handle of destination window
    UINT Msg, // message to send
    WPARAM wParam, // first message parameter
    LPARAM lParam // second message parameter
    );

    Parameters
    hWnd
    Handle to the window whose window procedure will receive the message. If this parameter is HWND_BROADCAST, the message is sent to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and pop-up windows; but the message is not sent to child windows.
    Msg
    Specifies the message to be sent.
    wParam
    Specifies additional message-specific information.
    lParam
    Specifies additional message-specific information.
    Return Values
    The return value specifies the result of the message processing and depends on the message sent.

    Remarks
    Applications that need to communicate using HWND_BROADCAST should use the RegisterWindowMessage function to obtain a unique message for inter-application communication.

    If the specified window was created by the calling thread, the window procedure is called immediately as a subroutine. If the specified window was created by a different thread, the system switches to that thread and calls the appropriate window procedure. Messages sent between threads are processed only when the receiving thread executes message retrieval code. The sending thread is blocked until the receiving thread processes the message.

    Windows CE: Windows CE does not support all the messages the desktop Windows platforms support. Before using SendMessage, check to make sure the message you are sending is supported.

    Ciao

  7. #7
    l'ho chiusa "semplicemente" perchè AVEVI deciso di chiudela tu...

    Credevo (leggendo il tuo secondo post) che ti riferissi esclusivamete

    al VB e non all'utilizzo delle API in generale.

    ...Terrible warlords, good warlords, and an english song

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.