91vpn 控制模块
来源:互联网 发布:sql根据条件删除数据 编辑:程序博客网 时间:2024/04/27 14:39
91vpn程序不能被控制,只能手动,所以增加了一些控制代码
实现了断开,连接,自动切换见代码
BOOL __stdcall Enum91VpnWindowsProc(HWND hWnd, LPARAM lParam)
{
TCHAR m_strTitle[MAX_PATH];
TCHAR m_strClass[MAX_PATH];
TCHAR m_strDisplay[MAX_PATH*2+10];
int controlCode=(int)lParam;
if(::GetWindowLong(hWnd,GWL_STYLE))//& WS_VISIBLE)
{
::GetWindowText(hWnd,m_strTitle,MAX_PATH-1);
::GetClassName(hWnd,m_strClass,MAX_PATH-1);
strcpy(m_strDisplay,m_strTitle);
strcat(m_strDisplay,":[");
strcat(m_strDisplay,m_strClass);
strcat(m_strDisplay,"]");
CString strClass,strTitle;
strClass.Format("%s",m_strClass);
strTitle.Format("%s",m_strTitle);
if(controlCode==0)
{
if(strTitle=="连接" )
{
if(strClass=="Button")
{
int ID=GetDlgCtrlID(hWnd);
::PostMessage(hWnd,WM_COMMAND, MAKEWPARAM(ID, BN_CLICKED), NULL);
::PostMessage(hWnd,WM_MOUSEMOVE, MK_LBUTTON, MAKELONG(0,0) );
::PostMessage(hWnd,WM_LBUTTONDOWN,MK_LBUTTON,MAKELPARAM(0,0));
::PostMessage(hWnd,WM_LBUTTONUP,MK_LBUTTON,MAKELPARAM(0,0));
return TRUE;
}
}
}
if(controlCode==5)
{
if(strTitle=="测试" )
{
if(strClass=="Button"&&pDlg->bClickButton==false)
{
pDlg->bClickButton=true;
int ID=GetDlgCtrlID(hWnd);
::PostMessage(hWnd,WM_COMMAND, MAKEWPARAM(ID, BN_CLICKED), NULL);
::PostMessage(hWnd,WM_MOUSEMOVE, MK_LBUTTON, MAKELONG(0,0) );
::PostMessage(hWnd,WM_LBUTTONDOWN,MK_LBUTTON,MAKELPARAM(0,0));
::PostMessage(hWnd,WM_LBUTTONUP,MK_LBUTTON,MAKELPARAM(0,0));
return TRUE;
}
}
}
if(controlCode==6)
{
if(strTitle=="关闭" )
{
if(strClass=="Button")
{
int ID=GetDlgCtrlID(hWnd);
::PostMessage(hWnd,WM_COMMAND, MAKEWPARAM(ID, BN_CLICKED), NULL);
Sleep(200);
::PostMessage(hWnd,WM_MOUSEMOVE, MK_LBUTTON, MAKELONG(0,0) );
Sleep(200);
::PostMessage(hWnd,WM_LBUTTONDOWN,MK_LBUTTON,MAKELPARAM(0,0));
Sleep(200);
::PostMessage(hWnd,WM_LBUTTONUP,MK_LBUTTON,MAKELPARAM(0,0));
return TRUE;
}
}
}if(controlCode==1)
{
if(strTitle=="断开" )
{
if(strClass=="Button")
{
int ID=GetDlgCtrlID(hWnd);
::PostMessage(hWnd,WM_COMMAND, MAKEWPARAM(ID, BN_CLICKED), NULL);
::PostMessage(hWnd,WM_MOUSEMOVE, MK_LBUTTON, MAKELONG(0,0) );
::PostMessage(hWnd,WM_LBUTTONDOWN,MK_LBUTTON,MAKELPARAM(0,0));
::PostMessage(hWnd,WM_LBUTTONUP,MK_LBUTTON,MAKELPARAM(0,0));
return TRUE;
}
}
}
if(controlCode==2)
{
if(strClass=="ComboBox")
{
HWND hParent=::GetParent(hWnd);
CString strParent;
int titleLength=strTitle.GetLength();
::GetWindowText(hParent,strParent.GetBufferSetLength(MAX_PATH-1),MAX_PATH-1);
if(strParent=="连接"&&pDlg->b91VpnChangeISDone==false)
{
RECT rect;
::GetWindowRect(hWnd,&rect);
CRect cRect(&rect);
int cWidth=cRect.Width();
int cHeight=cRect.Height();
if(cWidth>=160)
{
pDlg->b91VpnChangeISDone=true;
int ID=GetDlgCtrlID(hWnd);
int cbIndex = SendMessage(hWnd, CB_GETCURSEL, 0, 0);
int count = SendMessage(hWnd, CB_GETCOUNT, 0,0);
CString strCBtext;
SendMessage(hWnd,CB_GETLBTEXT,(WORD)cbIndex,(LONG)strCBtext.GetBufferSetLength(255));
pDlg->ShowResult("切换前%s",strCBtext);
bool bFind=false;
for(int i=cbIndex+1;i<count;i++)
{
SendMessage(hWnd,CB_GETLBTEXT,(WORD)i,(LONG)strCBtext.GetBufferSetLength(255));
if(strCBtext.Find("联通")!=-1&&strCBtext.Find("辽宁")!=-1)
{
SendMessage(hWnd, CB_SETCURSEL, i, 0);
bFind=true;
pDlg->ShowResult("切换后%s",strCBtext);
break;
}
}
if( bFind==false)
{
for(int i=0;i<count;i++)
{
SendMessage(hWnd,CB_GETLBTEXT,(WORD)cbIndex,(LONG)strCBtext.GetBufferSetLength(255));
if(strCBtext.Find("联通")!=-1&&strCBtext.Find("辽宁")!=-1)
{
SendMessage(hWnd, CB_SETCURSEL, cbIndex, 0);
bFind=true;
pDlg->ShowResult("从0切换后%s",strCBtext);
break;
}
}
}
return TRUE;
}
}
}
}
if(controlCode==3)
{
if(strClass=="ComboBox")
{
HWND hParent=::GetParent(hWnd);
CString strParent;
int titleLength=strTitle.GetLength();
::GetWindowText(hParent,strParent.GetBufferSetLength(MAX_PATH-1),MAX_PATH-1);
if(strParent=="连接")
{
RECT rect;
::GetWindowRect(hWnd,&rect);
CRect cRect(&rect);
int cWidth=cRect.Width();
int cHeight=cRect.Height();
if(cWidth>=160)
{
int cbIndex = SendMessage(hWnd, CB_GETCURSEL, 0, 0);
int count = SendMessage(hWnd, CB_GETCOUNT, 0,0);
CString strCBtext;
SendMessage(hWnd,CB_GETLBTEXT,(WORD)cbIndex,(LONG)strCBtext.GetBufferSetLength(255));
for(int i=0;i<count;i++)
{
SendMessage(hWnd,CB_GETLBTEXT,(WORD)i,(LONG)strCBtext.GetBufferSetLength(255));
pDlg->strArray91Ip.Add(strCBtext);
}
return TRUE;
}
}
}
}
if(controlCode==4)
{
if(strClass=="ComboBox")
{
HWND hParent=::GetParent(hWnd);
CString strParent;
int titleLength=strTitle.GetLength();
::GetWindowText(hParent,strParent.GetBufferSetLength(MAX_PATH-1),MAX_PATH-1);
if(strParent=="连接"&&pDlg->b91VpnChangeISDone==false)
{
RECT rect;
::GetWindowRect(hWnd,&rect);
CRect cRect(&rect);
int cWidth=cRect.Width();
int cHeight=cRect.Height();
if(cWidth>=160)
{
pDlg->b91VpnChangeISDone=true;
int ID=GetDlgCtrlID(hWnd);
int cbIndex = SendMessage(hWnd, CB_GETCURSEL, 0, 0);
int count = SendMessage(hWnd, CB_GETCOUNT, 0,0);
CString strCBtext;
SendMessage(hWnd,CB_GETLBTEXT,(WORD)cbIndex,(LONG)strCBtext.GetBufferSetLength(255));
pDlg->ShowResult("切换前%s",strCBtext);
bool bFind=false;
for(int i=0;i<count;i++)
{
SendMessage(hWnd,CB_GETLBTEXT,(WORD)i,(LONG)strCBtext.GetBufferSetLength(255));
if(strCBtext==pDlg->m_currentVPN_Name)
{
SendMessage(hWnd, CB_SETCURSEL, i, 0);
bFind=true;
pDlg->ShowResult("切换后%s",strCBtext);
break;
}
}
return TRUE;
}
}
}
}
::EnumChildWindows(hWnd,Enum91VpnWindowsProc,controlCode);
}
return TRUE;
}
完整代码联系我99596464
- 91vpn 控制模块
- VPN控制
- VPN模块的分析
- VPN模块的分析
- VPN模块的分析
- VPN模块的分析
- C# 完美实现VPN控制
- Froyo中VPN模块的分析
- Ubuntu下ZJU的VPN模块
- 通过FreeRADIUS来控制VPN流量
- 使用vpn远程控制S7 1200
- 时间控制模块
- 控制模块的困惑
- 时钟控制模块ALTCLKCTRL
- 测试时间模块控制
- android模块版本控制
- __all__=[]模块控制
- SDRAM控制模块图
- 任务监听器
- nonatomic, retain,weak,strong用法详解
- 算术移位和逻辑移位实现分析
- POJ 1032
- java面试题系列9
- 91vpn 控制模块
- 存储器统一编址和I/O独立编址
- ASP.NET-禁用模态窗口缓存方法
- IT项目管理的六种致命错误:忘记项目目标
- ServerXmlHttp和XmlHttp的一些总结
- 二分图学习小记 Poj 1274 The Perfect Stall
- make bigger choices, take courageous risks
- 执行监听器 ExecutionListener
- boost------ref的使用(Boost程序库完全开发指南)读书笔记