//receive.cpp
#include"string"
#include"iostream"
#include"windows.h"
#include"winbase.h"
using namespace std;
void main()
{
// LPMS
//char* ch[100];
//MSG* a;
// static UINT WM_MY_MESSAGE=RegisterWindowMessage("Message");
if(GetMessage(NULL,NULL,0,0))
{
string aa;
//aa=a->wParam;
//cout << aa <<endl;
cout << "连接上了"<<endl;
}
else
{
cout <<"发送方不存在!!!exit"<<endl;
}
system("pause");
}
//send.cpp
#include"iostream"
#include"windows.h"
#include"winbase.h"
#include"string"
using namespace std;
void main()
{
static UINT WM_MY_MESSAGE=RegisterWindowMessage("Message");
char *p="woaizhonghua";
label:
HWND hw=FindWindow("ConsoleWindowClass",NULL);
if(!hw)
{
cout <<"接受方不存在!!! "<<endl;
system("pause");
return ;
}
/*COPYDATASTRUCT cds;
cds.cbData=sizeof(p);
// cds.dwData=0;
cds.lpData=p;
//HANDLE recV;
// GetActiveWindow()->GetSafeHwnd();
SendMessage(GetActiveWindow()->GetSafeHwnd(),WM_COPYDATA,0,(LPARAM) &cds);*/
SendMessage(hw,WM_MY_MESSAGE,(int)p,0);
if(hw) goto label;
system("pause");
}
别笑啊,没学过vc,这两天在网上看着写的,真的很困难,哪位帮忙看看