掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
他のプログラムにデータを渡したい (ID:17431)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
しつこいですが^^;、資料が見つかりましたので、載せますね。 アトムを使用したアプリ間の通信の例です。 サーバーアプリ上のボタンをクリックすると、エディットボックスの内容が クライアントアプリに送信されます。 クライアントアプリのフォームのキャプションを クライアント として下さい。 サーバーアプリのソースコード======================================== unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; const WM_MYMSG = WM_USER + 100; type TForm1 = class(TForm) Edit1: TEdit; Button1: TButton; procedure Button1Click(Sender: TObject); private { Private 宣言 } public { Public 宣言 } end; var Form1: TForm1; implementation {$R *.DFM} procedure TForm1.Button1Click(Sender: TObject); var H: THandle; A: TAtom; begin H := FindWindow(nil, 'クライアント'); A := GlobalAddAtom(PChar(Edit1.Text)); SendMessage(H, WM_MYMSG, A, 0); GlobalDeleteAtom(A); end; end. クライアントアプリのソースコード==================================== unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; const WM_MYMSG = WM_USER + 100; type TForm1 = class(TForm) Label1: TLabel; private { Private 宣言 } procedure WMUserMessage(var Msg: TMessage); message WM_MYMSG; public { Public 宣言 } end; var Form1: TForm1; implementation {$R *.DFM} procedure TForm1.WMUserMessage(var Msg: TMessage); var s: PChar; begin s := StrAlloc(255); GlobalGetAtomName(Msg.wParam, PChar(s), 255); Label1.Caption := s; StrDispose(s); end; end.
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.