进程通信 - SendMessage

核心代码:


	发送端代码:							
								
	HWND hwnd = ::FindWindow(NULL,TEXT("接收端窗口名"));							
	if(hwnd == NULL)							
	{							
		MessageBox(0,TEXT("没找到窗口"),TEXT("ERROR"),MB_OK);						
	}							
	else							
	{							
		// 发送消息  						
		//SendMessage(hwnd,WM_USER+0x1,NULL, (LPARAM)100); 						
		PostMessage(hwnd,WM_USER+0x1, NULL, (LPARAM)100);						
	}							
								
								
	接收端代码:							
								
	switch(uMsg)							
	{							
	case WM_CLOSE:							
		{						
			EndDialog(hDlg,0);					
			break;					
		}						
	case WM_USER+0x1:							
		{						
			DWORD x = wParam;					
			DWORD y = lParam;					
								
			MessageBox(0,0,0,0);					
			break;					
		}						
	case WM_COMMAND:							
								
		switch (LOWORD (wParam))						
		{						
		case IDC_BUTTON_RECV:						
			{					
								
								
				return TRUE;				
			}					
		}						
		break ;						
	}							
								
								
进程通信 - PostMessage.rar



很简单的通信方式!


原文链接: 进程通信 - SendMessage 版权所有,转载时请注明出处,违者必究。
注明出处格式:流沙团 ( https://gyarmy.com/post-395.html )

发表评论

0则评论给“进程通信 - SendMessage”