- 1
- 2
- 3
short lPort = atoi(szTemp);
if (lPort <= 0 || lPort > 65535)
lPort = 80;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
Всего: 38
+116
short lPort = atoi(szTemp);
if (lPort <= 0 || lPort > 65535)
lPort = 80;
+109
public static bool IsLocalAddress(IPAddress address)
{
if (address.ToString() == IPAddress.Loopback.ToString())
{
return true;
}
foreach (IPAddress address2 in LocalAddresses)
{
if (address2.ToString() == address.ToString())
{
return true;
}
}
return false;
}
Выдрано решарпером из одного коммерческой библиотеки.
+168
void __fastcall TForm1::ShowBits(unsigned char data)
{
if(data&0x1)ImBit0->Canvas->Brush->Color=0x0000FF00;
else ImBit0->Canvas->Brush->Color=clRed;
ImBit0->Canvas->FillRect(TRect(0,0,ImBit0->Width,ImBit0->Height));
if(data&0x2)ImBit1->Canvas->Brush->Color=0x0000FF00;
else ImBit1->Canvas->Brush->Color=clRed;
ImBit1->Canvas->FillRect(TRect(0,0,ImBit1->Width,ImBit1->Height));
if(data&0x4)ImBit2->Canvas->Brush->Color=0x0000FF00;
else ImBit2->Canvas->Brush->Color=clRed;
ImBit2->Canvas->FillRect(TRect(0,0,ImBit2->Width,ImBit2->Height));
if(data&0x8)ImBit3->Canvas->Brush->Color=0x0000FF00;
else ImBit3->Canvas->Brush->Color=clRed;
ImBit3->Canvas->FillRect(TRect(0,0,ImBit3->Width,ImBit3->Height));
if(data&0x10)ImBit4->Canvas->Brush->Color=0x0000FF00;
else ImBit4->Canvas->Brush->Color=clRed;
ImBit4->Canvas->FillRect(TRect(0,0,ImBit4->Width,ImBit4->Height));
if(data&0x20)ImBit5->Canvas->Brush->Color=0x0000FF00;
else ImBit5->Canvas->Brush->Color=clRed;
ImBit5->Canvas->FillRect(TRect(0,0,ImBit5->Width,ImBit5->Height));
if(data&0x40)ImBit6->Canvas->Brush->Color=0x0000FF00;
else ImBit6->Canvas->Brush->Color=clRed;
ImBit6->Canvas->FillRect(TRect(0,0,ImBit6->Width,ImBit6->Height));
if(data&0x80)ImBit7->Canvas->Brush->Color=0x0000FF00;
else ImBit7->Canvas->Brush->Color=clRed;
ImBit7->Canvas->FillRect(TRect(0,0,ImBit7->Width,ImBit7->Height));
}
Отображение состояния битов байта
+159
Наконец-то http://goo.gl/SjgUj
+148
int getGKnumber()
{
return 7000;
}
просто гет :)
+123
this.Border1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(111)))), ((int)(((byte)(111)))), ((int)(((byte)(111)))));
Встретилось такое внутри сгенеренной системой InitializeComponent()
+157
void CVC6_SampleCodeDlg::OnButtonSaveframe()
{
// TODO: Add your control notification handler code here
SYSTEMTIME lpSysTime;
GetLocalTime(&lpSysTime);
long Dims = SafeArrayGetDim(pvBuffer.parray);
if(Dims != 1)
return;
char *pbuf = (char*)malloc(m_FrameSize);
char *pfinal = pbuf;
for(long i=0;i<m_FrameSize;i++)
{
SafeArrayGetElement(pvBuffer.parray, &i, pfinal++);
}
FILE* fSaveFile;
CString saveName;
if(m_vportsdk.GetGetStreamType() == 1)
saveName.Format(".//%d%d%d_%d%d%d.mpg4",lpSysTime.wYear, lpSysTime.wMonth, lpSysTime.wDay,
lpSysTime.wHour, lpSysTime.wMinute, lpSysTime.wSecond);
else if(m_vportsdk.GetGetStreamType() == 2)
saveName.Format(".//%d%d%d_%d%d%d.jpg",lpSysTime.wYear, lpSysTime.wMonth, lpSysTime.wDay,
lpSysTime.wHour, lpSysTime.wMinute, lpSysTime.wSecond);
if((fSaveFile = fopen((LPCTSTR)saveName,"wb"))!=NULL)
{
fwrite(pbuf, 1, m_FrameSize, fSaveFile);
fclose(fSaveFile);
}
SafeArrayUnaccessData(pvBuffer.parray);
delete pbuf;
pbuf = NULL;
}
VPort ActiveX SDK PLUS от Moxa
часть 5. Хватит пока :)
+154
void CVC6_SampleCodeDlg::OnButtonSetpreset()
{
// TODO: Add your control notification handler code here
CComboBox *pCombobox = (CComboBox *) GetDlgItem(IDC_COMBO_PRESETNAME);
CString strPresetName;
GetDlgItem(IDC_EDIT_PRESETNAME)->GetWindowText(strPresetName);
if(strPresetName != "")
m_vportsdk.SavePresetPosition(strPresetName, (pCombobox->GetCurSel()+1));
else{
GetDlgItem(IDC_COMBO_PRESETNAME)->GetWindowText(strPresetName);
m_vportsdk.SavePresetPosition(strPresetName, (pCombobox->GetCurSel()+1));
}
}
VPort ActiveX SDK PLUS от Moxa
часть 4
+155
void CVC6_SampleCodeDlg::OnCHECKForceGDI()
{
// TODO: Add your control notification handler code here
CButton *pBut = (CButton *) GetDlgItem(IDC_CHECK_ForceGDI);
m_vportsdk.SetForceGDI(pBut->GetCheck());
if(pBut->GetCheck() == 0)
m_ForceGDI = false;
else if(pBut->GetCheck() == 1)
m_ForceGDI = true;
}
VPort ActiveX SDK PLUS от Moxa
часть 3
+156
void CVC6_SampleCodeDlg::Onbuttonstartrecord()
{
// TODO: Add your control notification handler code here
CString strFileName, strFileTime, strFileSize, strTemp;
GetDlgItem(IDC_EDIT_filepath)->GetWindowText(strFileName);
GetDlgItem(IDC_EDIT_filetime)->GetWindowText(strFileTime);
GetDlgItem(IDC_EDIT_filelength)->GetWindowText(strFileSize);
GetDlgItem(IDC_button_startrecord)->GetWindowText(strTemp);
m_vportsdk.SetRecordVideoPath(strFileName);
m_vportsdk.SetRecordMaxFileTimeLength(atoi(strFileTime));
m_vportsdk.SetRecordMaxFileSize(atoi(strFileSize));
CComboBox *pRecordType = (CComboBox *) GetDlgItem(IDC_COMBO_recordtype);
if(strTemp == "Start Record"){
if(pRecordType->GetCurSel() == 0)
m_vportsdk.StartRecording(0);
else
m_vportsdk.StartRecording(1);
GetDlgItem(IDC_button_startrecord)->SetWindowText("Stop Record");
}
else{
if(pRecordType->GetCurSel() == 0)
m_vportsdk.StopRecording(0);
else
m_vportsdk.StopRecording(1);
GetDlgItem(IDC_button_startrecord)->SetWindowText("Start Record");
}
}
VPort ActiveX SDK PLUS от Moxa
часть 2