المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : list and ip control in mfc



C++ Programming
06-29-2009, 01:41 PM
hello,

i want to copy the content of ip control and add it to a list control. so try to do this ----


void Cserver_side_mfcDlg::OnBnClickedOk2()
{
BYTE m_M1, m_M2, m_M3, m_M4;
DWORD s = 0;
char ss[20] = {0};
UpdateData();
m_ipAdd.GetAddress(m_M1, m_M2, m_M3, m_M4);
m_ipList.InsertItem(s++, LPCTSTR(m_M1));

}


it compiles without any error but when i run it and click ok, it shows the error ---

Unhandled exception at 0x746bc348 in server_side_mfc.exe: 0xC0000005: Access violation reading ******** 0x00000017.

i also tried ----
void Cserver_side_mfcDlg::OnBnClickedOk2()
{
BYTE m_M1, m_M2, m_M3, m_M4;
DWORD s = 0;
char ss[20] = {0};
UpdateData();
m_ipAdd.GetAddress(m_M1, m_M2, m_M3, m_M4);
sprintf_s(ss, "%s:%s:%s:%s", m_M1, m_M2, m_M3, m_M4);
m_ipList.InsertItem(s++, (LPCTSTR)ss);

}

error ---

Unhandled exception at 0x5cd3e9ee (msvcr90d.dll) in server_side_mfc.exe: 0xC0000005: Access violation reading ******** 0x0000006f.


i also tried something like this which is working without any problem ----


void Cserver_side_mfcDlg::OnBnClickedOk2()
{
BYTE m_M1, m_M2, m_M3, m_M4;
DWORD s = 0;
char ss[20] = {0};
UpdateData();
m_ipAdd.GetAddress(m_M1, m_M2, m_M3, m_M4);
m_ipList.InsertItem(s++, _T("ABC"));

}


please help.