模拟游戏发送数据封包的前提是网页游戏,内置的flash的网页游戏。
我是将webbrowser控件内置到MFC程序中,再自己的程序中打开网页游戏。
获取游戏句柄,即flash控件的句柄:最简单的方法,当然还可以遍历控件来获取:
CPoint a;
GetCursorPos(&a);
HWND thWnd = ::WindowFromPoint(a);
游戏是在自己的程序里运行的,FLASH游戏连接服务器一般使用的是socket。如果他游戏的socket自己的程序能调用,岂不是很爽。可以实现一些很不错的功能。你懂的!
其实是有一个这样的API:
int WSADuplicateSocket(
__in SOCKET s,
__in DWORD dwProcessId,
__out LPWSAPROTOCOL_INFO lpProtocolInfo
);
s
Descriptor identifying the local socket.
dwProcessId
Process identifier of the target process in which the duplicated socket will be used.
lpProtocolInfo
Pointer to a buffer, allocated by the client, that is large enough to contain a WSAPROTOCOL_INFO structure. The service provider copies the protocol information structure contents to this buffer.
这个API就是将socket的相关