AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Win32/Win64 API (native code) Delphi Text zur anderer Anwendung senden
Thema durchsuchen
Ansicht
Themen-Optionen

Text zur anderer Anwendung senden

Ein Thema von Sugar · begonnen am 18. Nov 2013 · letzter Beitrag vom 20. Nov 2013
 
hathor
(Gast)

n/a Beiträge
 
#17

AW: Text zur anderer Anwendung senden

  Alt 19. Nov 2013, 18:05
Communicate between processes using windows messaging

http://www.delphidabbler.com/tips/51

Delphi-Quellcode:
SENDER:

// wmCopyData
// Allows inter-process communications via Windows WM_COPYDATA messaging.
procedure wmCopyData(WndClass:PChar;WndTitle:PChar;Msg:String);
var
  hWnd : THandle // Handle to target window to receive message
  cds : CopyDataStruct; // Structure to package the outbound message
begin
  // Find target window
  hWnd := FindWindow(PChar(WndClass), PChar(WndTitle));
  try
    cds.dwData := 0
    cds.cbData := Length(Msg); // Length of message
    cds.lpData := PChar(Msg); // Actual message
    // The following function is not necessary for this to work
    SetForegroundWindow(hWnd); // Pulls target window up top
    SendMessage(hWnd, wm_CopyData, 0, Integer(@cds));
send the message
  finally
    CloseHandle(hWnd) // Close handle to target
  end;
end;
// A typical call to this procedure would be:

wmCopyData('NOTEPAD','Untitled - Notepad','Test Message');

//----------------------------------------------------------------
RECEIVER:

// Add a custom message handler so our app gets notified upon receipt
private
  procedure WMGetData(var Msg: TWMCopyData); message WM_COPYDATA;

// wmGetData
// Receives inbound messages - Callback function
// Called from message handler
procedure TForm1.wmGetData(var Msg: TWMCopyData);
var
  sText: array[0..255] of Char; // Create an array to store message in
begin
  // Cast inbound data structure into a character array
  StrLCopy(sText, Msg.CopyDataStruct.lpData, Msg.CopyDataStruct.cbData);
  Edit1.Text := sText;
end;
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 06:52 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz