程序傳送訊息

2022-09-14 05:09:09 字數 1012 閱讀 9325

#region 程序傳送訊息

public

const

int wm_copydata = 0x004a

; [dllimport(

"user32.dll

", entrypoint = "

findwindow")]

public

static

extern intptr findwindow(string lpclassname, string

lpwindowname);

//////

定義使用者要傳遞的訊息的資料

///[structlayout(layoutkind.sequential)]

public

struct

copydatastruct

[dllimport(

"user32.dll

", entrypoint = "

sendmessage")]

private

static

extern

intsendmessage(

intptr hwnd,

//目標窗體控制代碼

int msg, //

wm_copydata

int wparam, //

自定義數值

ref copydatastruct lparam //

結構體);

//////

傳送訊息

/// ///

window的title,建議加上guid,不會重複

///要傳送的字串

public

static

void sendmessage(string windowname, string

strmsg)

}#endregion

跨程序訊息以及資料傳送

跨程序訊息以及資料傳送 訊息機制是windows的乙個特點。在windows開發中基本上都會用到訊息傳送以及接收,突別是對於ui介面開發這一塊。程序之間相互通訊的方式有很多,其中包括跨程序訊息。訊息傳送 最常用的是使用sendmessage以及postmessage 系統api函式,訊息發到指定的視...

程序間傳遞訊息(傳送和接收系統訊息)

unit unit1 inte ce uses windows,messages,sysutils,variants,classes,graphics,controls,forms,dialogs,stdctrls type tform1 class tform button1 tbutton pr...

核心模組向使用者程序傳送訊息

kpp.c include include include include include include include include include include include include include include include include include include ...