LRESULT CMainFrame::OnRegRightRenameOk(WPARAM wParam,LPARAM lParam) { char m_KeyName[2048] = {0}; if(!GetMyRegLeftPath(pRegTreeView->GetTreeCtrl().GetSelectedItem() ,m_KeyName)) return FALSE; char m_ItemName[2048] = {0}; char m_NewKeyName[2048] = {0}; char m_OldKeyName[2048] = {0}; strcpy(m_NewKeyName,m_KeyName); strcpy(m_OldKeyName,m_KeyName); int nItem = (int) lParam; wsprintf(m_ItemName,"%s",pRegListView->GetListCtrl().GetItemText(nItem,0)); strcat(m_NewKeyName,m_ItemName); strcat(m_OldKeyName,(char*) wParam); m_MissionData.m_Command = CLIENT_REG_RENAME_VALUE; memset(m_MissionData.m_TransData,0,2048); memcpy(m_MissionData.m_TransData,m_NewKeyName,strlen(m_NewKeyName)); memcpy(&m_MissionData.m_TransData[1024],m_OldKeyName,strlen(m_OldKeyName)); m_MissionData.m_TransLen = 2048; if(!ProcessOneTrans(&m_MissionData)) { ShowResponse(m_MissionData.m_Command); pRegListView->GetListCtrl().SetItemText(nItem,0,(char*) wParam); return FALSE; } if(m_MissionData.m_Command != 0) { ShowResponse(m_MissionData.m_Command); pRegListView->GetListCtrl().SetItemText(nItem,0,(char*) wParam); } return TRUE; }
void CMainFrame::OnProcessFlush() { m_MissionData.m_TransLen = 0; m_MissionData.m_Command = CLIENT_PROCESS_LIST; if(!ProcessOneTrans(&m_MissionData)) { ShowResponse(m_MissionData.m_Command); return ; } if(m_MissionData.m_Command == NOT_FIND_ANY_FILE) { pProcessListView->GetListCtrl().DeleteAllItems(); return ; } if(m_MissionData.m_Command != 0) { ShowResponse(m_MissionData.m_Command); return ; } DWORD dwFileSize = m_MissionData.m_TransLen; BYTE * m_DesBuf = (LPBYTE) m_MissionData.m_TransData; pProcessListView->GetListCtrl().DeleteAllItems(); LPPROCESSLIST pList = (LPPROCESSLIST) m_DesBuf; for(DWORD i = 0; i < (dwFileSize/sizeof(PROCESSLIST)); i++) { pProcessListView->InsertMyItem(&pList[i]); } }
int CMainFrame::OnRegRightNewValue(int IsSz) { CMyRenameDlg dlg; if(dlg.DoModal() != IDOK) return 0; int nItem = 0; if(IsSz == REG_VALUE_STR) { nItem = pRegListView->GetListCtrl().InsertItem (pRegListView->GetListCtrl().GetItemCount(),dlg.m_RegName,1); pRegListView->GetListCtrl().SetItemText(nItem,1,"REG_SZ"); pRegListView->GetListCtrl().SetItemText(nItem,2,""); } else if(IsSz == REG_VALUE_INT) { nItem = pRegListView->GetListCtrl().InsertItem (pRegListView->GetListCtrl().GetItemCount(),dlg.m_RegName,0); pRegListView->GetListCtrl().SetItemText(nItem,1,"REG_DWORD"); pRegListView->GetListCtrl().SetItemText(nItem,2,"0x00000000(0)"); } else { nItem = pRegListView->GetListCtrl().InsertItem (pRegListView->GetListCtrl().GetItemCount(),dlg.m_RegName,0); pRegListView->GetListCtrl().SetItemText(nItem,1,"REG_BINARY"); pRegListView->GetListCtrl().SetItemText(nItem,2,"00"); } char m_KeyName[1024] = {0}; if(!GetMyRegLeftPath(pRegTreeView->GetTreeCtrl().GetSelectedItem() ,m_KeyName)) return -1; m_MissionData.m_Command = CLIENT_REG_CREATE_VALUE; memset(m_MissionData.m_TransData,0,2048); memcpy(m_MissionData.m_TransData,m_KeyName,strlen(m_KeyName)); m_MissionData.m_TransData[1024] = IsSz; strcpy(&m_MissionData.m_TransData[1025], dlg.m_RegName); m_MissionData.m_TransLen = 1025 + strlen(dlg.m_RegName); if(!ProcessOneTrans(&m_MissionData)) { ShowResponse(m_MissionData.m_Command); pRegListView->GetListCtrl().DeleteItem(nItem); return -1; } if(m_MissionData.m_Command != 0) { ShowResponse(m_MissionData.m_Command); pRegListView->GetListCtrl().DeleteItem(nItem); return -1; } return nItem; }
void CMainFrame::OnProcessKill() { int nItem = pProcessListView->GetListCtrl().GetNextItem(-1, LVNI_SELECTED); char m_TmpBuf[2048]; memset(m_TmpBuf,0,sizeof(m_TmpBuf)); strcpy(m_TmpBuf,(LPCTSTR) pProcessListView->GetListCtrl().GetItemText(nItem,0)); *((DWORD*) m_MissionData.m_TransData) = atol(m_TmpBuf); m_MissionData.m_TransLen = sizeof(DWORD); m_MissionData.m_Command = CLIENT_PROCESS_KILL; if(!ProcessOneTrans(&m_MissionData)) { ShowResponse(m_MissionData.m_Command); return ; } if(m_MissionData.m_Command != 0) { ShowResponse(m_MissionData.m_Command); return ; } pProcessListView->GetListCtrl().DeleteItem(nItem); }
void CMainFrame::OnRegLeftDelete() { HTREEITEM hItem = pRegTreeView->GetTreeCtrl().GetSelectedItem(); char m_KeyName[1024] = {0}; if(!GetMyRegLeftPath(hItem,m_KeyName)) return; m_MissionData.m_Command = CLIENT_REG_DELETE_KEY; strcpy(m_MissionData.m_TransData,m_KeyName); m_MissionData.m_TransLen = strlen(m_MissionData.m_TransData); if(!ProcessOneTrans(&m_MissionData)) { ShowResponse(m_MissionData.m_Command); return ; } if(m_MissionData.m_Command != 0) { ShowResponse(m_MissionData.m_Command); return ; } pRegTreeView->GetTreeCtrl().DeleteItem(hItem); }
void CMainFrame::OnRegRightDelete() { char m_KeyName[1024] = {0}; if(!GetMyRegLeftPath(pRegTreeView->GetTreeCtrl().GetSelectedItem() ,m_KeyName)) return; int nItem = pRegListView->GetListCtrl().GetNextItem(-1,LVNI_SELECTED); m_MissionData.m_Command = CLIENT_REG_DELETE_VALUE; wsprintf(m_MissionData.m_TransData,"%s%s", m_KeyName,pRegListView->GetListCtrl().GetItemText(nItem,0)); m_MissionData.m_TransLen = strlen(m_MissionData.m_TransData); if(!ProcessOneTrans(&m_MissionData)) { ShowResponse(m_MissionData.m_Command); return ; } if(m_MissionData.m_Command != 0) { ShowResponse(m_MissionData.m_Command); return ; } pRegListView->GetListCtrl().DeleteItem(nItem); }
/*---------------------------------------------------------------------- | TestHttpGet +---------------------------------------------------------------------*/ static void TestHttpGet(const char* arg, ShowMode mode) { NPT_HttpUrl url(arg); NPT_HttpRequest request(url, NPT_HTTP_METHOD_GET); NPT_HttpClient client; NPT_HttpResponse* response; NPT_Result result = client.SendRequest(request, response); NPT_Debug("SendRequest returned %d\n", result); if (NPT_FAILED(result)) return; ShowResponse(response, mode); delete response; }
/*---------------------------------------------------------------------- | TestHttpGetWithProxy +---------------------------------------------------------------------*/ static void TestHttpGetWithProxy(const char* arg) { NPT_HttpUrl url(arg); NPT_HttpRequest request(url, NPT_HTTP_METHOD_GET); NPT_HttpClient client; NPT_HttpResponse* response; client.SetProxy("proxy", 8080); NPT_Result result = client.SendRequest(request, response); NPT_Debug("SendRequest returned %d\n", result); if (NPT_FAILED(result)) return; ShowResponse(response); delete response; }
/*---------------------------------------------------------------------- | TestHttpChunked +---------------------------------------------------------------------*/ static void TestHttpChunked(const char* arg) { NPT_HttpUrl url(arg); NPT_HttpRequest request(url, NPT_HTTP_METHOD_GET); request.SetProtocol(NPT_HTTP_PROTOCOL_1_1); NPT_HttpClient client; NPT_HttpResponse* response; NPT_Result result = client.SendRequest(request, response); NPT_Debug("SendRequest returned %d\n", result); if (NPT_FAILED(result)) return; ShowResponse(response, SHOW_MODE_STREAM_BLOCKING); delete response; }
/*---------------------------------------------------------------------- | TestHttpPost +---------------------------------------------------------------------*/ static void TestHttpPost(const char* arg) { NPT_HttpUrl url(arg); NPT_HttpRequest request(url, NPT_HTTP_METHOD_POST); NPT_HttpClient client; NPT_HttpResponse* response; NPT_HttpEntity* body_entity = new NPT_HttpEntity(); NPT_InputStreamReference body_stream(new NPT_MemoryStream((void*)"hello blabla", 12)); body_entity->SetInputStream(body_stream); request.SetEntity(body_entity); NPT_Result result = client.SendRequest(request, response); NPT_Debug("SendRequest returned %d\n", result); if (NPT_FAILED(result)) return; ShowResponse(response); delete response; }
void CMainFrame::OnRegRightModify() { char m_KeyName[1024] = {0}; if(!GetMyRegLeftPath(pRegTreeView->GetTreeCtrl(). GetSelectedItem(),m_KeyName)) return; int nItem = -1; nItem = pRegListView->GetListCtrl().GetNextItem(-1,LVNI_SELECTED); char m_Name[1024] = {0}; char m_Value[1024] = {0}; char m_OldValue[1024] = {0}; BOOL m_IsDigital = FALSE; strcpy(m_Name,(LPCTSTR) pRegListView->GetListCtrl().GetItemText(nItem,0)); strcpy(m_Value,(LPCTSTR) pRegListView->GetListCtrl().GetItemText(nItem,2)); strcpy(m_OldValue,m_Value); if(pRegListView->GetListCtrl().GetItemText(nItem,1) == "REG_DWORD") m_IsDigital = REG_VALUE_INT; else if(pRegListView->GetListCtrl().GetItemText(nItem,1) == "REG_SZ") m_IsDigital = REG_VALUE_STR; else m_IsDigital = REG_VALUE_BIN; CMyRegEditValue dlg(m_Name,m_Value,m_IsDigital); if(dlg.DoModal() != IDOK) return; strcpy(m_Value,(LPCTSTR) dlg.m_Value); m_MissionData.m_Command = CLIENT_REG_EDIT_VALUE; memset(m_MissionData.m_TransData,0,2048); strcat(m_KeyName,m_Name); memcpy(m_MissionData.m_TransData,m_KeyName,1024); if(m_IsDigital == REG_VALUE_BIN) AscToBcd((BYTE*) m_Value,(BYTE*) &m_MissionData.m_TransData[1024] , strlen(m_Value)); else memcpy(&m_MissionData.m_TransData[1024],m_Value,1024); m_MissionData.m_TransData[2048] = m_IsDigital; m_MissionData.m_TransData[2049] = strlen(m_Value)/2; m_MissionData.m_TransLen = 2050; if(!ProcessOneTrans(&m_MissionData)) { ShowResponse(m_MissionData.m_Command); pRegListView->GetListCtrl().SetItemText(nItem,2,m_OldValue); return ; } if(m_MissionData.m_Command != 0) { ShowResponse(m_MissionData.m_Command); pRegListView->GetListCtrl().SetItemText(nItem,2,m_OldValue); return ; } if(m_IsDigital == REG_VALUE_INT) { char m_Tmpbuf[40] = {0}; sprintf(m_Tmpbuf,"0x%08x(%d)",atol(m_Value), atol(m_Value)); pRegListView->GetListCtrl().SetItemText(nItem,2,m_Tmpbuf); } else pRegListView->GetListCtrl().SetItemText(nItem,2,m_Value); }
LRESULT CMainFrame::OnRegLeftDbClick(WPARAM wParam,LPARAM lParam) { HTREEITEM hItem = (HTREEITEM) wParam; if(hItem == NULL || hItem == pRegTreeView->GetTreeCtrl().GetRootItem() || m_MissionData.m_RecvSocket == 0) return FALSE; char m_KeyName[1024] = {0}; if(!GetMyRegLeftPath(hItem,m_KeyName)) return FALSE; m_MissionData.m_Command = CLIENT_REG_QUERY; strcpy(m_MissionData.m_TransData,m_KeyName); m_MissionData.m_TransLen = strlen(m_KeyName); if(!ProcessOneTrans(&m_MissionData)) { ShowResponse(m_MissionData.m_Command); return FALSE; } if(m_MissionData.m_Command == NOT_FIND_ANY_FILE) { pRegListView->GetListCtrl().DeleteAllItems(); pRegListView->GetListCtrl().InsertItem(0,"(默认)",1); pRegListView->GetListCtrl().SetItemText(0,1,"REG_SZ"); pRegListView->GetListCtrl().SetItemText(0,2,"(数值未设置)"); DisplayButton(&pRegTreeView->GetTreeCtrl(),hItem,0); return FALSE; } else if(m_MissionData.m_Command != 0) { ShowResponse(m_MissionData.m_Command); DisplayButton(&pRegTreeView->GetTreeCtrl(),hItem,0); return FALSE; } DWORD dwFileSize = m_MissionData.m_TransLen; BYTE * m_DesBuf = (LPBYTE) m_MissionData.m_TransData; if (pRegTreeView->GetTreeCtrl().ItemHasChildren(hItem)) { HTREEITEM hNextItem; HTREEITEM hChildItem = pRegTreeView->GetTreeCtrl().GetChildItem(hItem); while (hChildItem != NULL) { hNextItem = pRegTreeView->GetTreeCtrl().GetNextItem(hChildItem,TVGN_NEXT); pRegTreeView->GetTreeCtrl().DeleteItem(hChildItem); hChildItem = hNextItem; } } pRegListView->GetListCtrl().DeleteAllItems(); REGINFO m_RegInfo = {0}; TV_INSERTSTRUCT tvstruct; int nItem = 0; BOOL IsHasChild = FALSE; for(ULONG i = 0; i < (dwFileSize/sizeof(REGINFO)); i++) { memset(&m_RegInfo,0,sizeof(REGINFO)); memcpy(&m_RegInfo,m_DesBuf + i * sizeof(REGINFO),sizeof(REGINFO)); m_RegInfo.m_Name[m_RegInfo.m_NameLen] = 0; if(!m_RegInfo.m_IsKey) { if(m_RegInfo.m_DataType == REG_SZ) { nItem = pRegListView->GetListCtrl().InsertItem (pRegListView->GetListCtrl().GetItemCount(),m_RegInfo.m_Name,1); pRegListView->GetListCtrl().SetItemText(nItem,1,"REG_SZ"); m_RegInfo.m_Data[m_RegInfo.m_Datalen] = 0; pRegListView->GetListCtrl().SetItemText(nItem,2,m_RegInfo.m_Data); } else if(m_RegInfo.m_DataType == REG_BINARY) { nItem = pRegListView->GetListCtrl().InsertItem (pRegListView->GetListCtrl().GetItemCount(),m_RegInfo.m_Name,0); pRegListView->GetListCtrl().SetItemText(nItem,1,"REG_BINARY"); char m_Tmpbuf[4096] = {0}; BcdToAsc((BYTE*) m_RegInfo.m_Data,(BYTE*) m_Tmpbuf,m_RegInfo.m_Datalen); pRegListView->GetListCtrl().SetItemText(nItem,2,m_Tmpbuf); } else { nItem = pRegListView->GetListCtrl().InsertItem (pRegListView->GetListCtrl().GetItemCount(),m_RegInfo.m_Name,0); pRegListView->GetListCtrl().SetItemText(nItem,1,"REG_DWORD"); char m_Tmpbuf[40] = {0}; sprintf(m_Tmpbuf,"0x%08lx(%ld)",(UINT) *((DWORD*) m_RegInfo.m_Data), (UINT) *((DWORD*) m_RegInfo.m_Data)); pRegListView->GetListCtrl().SetItemText(nItem,2,m_Tmpbuf); } } else { tvstruct.hParent = hItem; tvstruct.hInsertAfter = TVI_LAST; tvstruct.item.iImage = 0; tvstruct.item.iSelectedImage = 1; tvstruct.item.pszText = m_RegInfo.m_Name; tvstruct.item.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT; HTREEITEM m_Parent = pRegTreeView->GetTreeCtrl().InsertItem(&tvstruct); DisplayButton(&pRegTreeView->GetTreeCtrl(),m_Parent,1); pRegTreeView->GetTreeCtrl().SetItemData(m_Parent,0); IsHasChild = TRUE; } } if(!IsHasChild) { DisplayButton(&pRegTreeView->GetTreeCtrl(),hItem,0); } pRegTreeView->GetTreeCtrl().Expand(hItem,TVE_EXPAND); return TRUE; }