Exemplo n.º 1
0
 public DNSRegInfo()
 {
     m_btUserName = new byte[32];
     m_btPwd      = new byte[32];
     m_stNvs      = new NvsSingle();
     m_stReserve  = new Reserve();
 }
Exemplo n.º 2
0
 public REG_NVS()
 {
     m_btPrimaryDS = new byte[32];
     m_stNvs       = new NvsSingle();
     m_btRegTime   = new byte[32];
     m_stReserve   = new Reserve();
 }
Exemplo n.º 3
0
        //获取NVS列表的回调函数,必须使用IntPtr,否则传值失败
        private void NVSListNotify(Int32 _iCount, IntPtr _pNvs)
        {
            for (int i = 0; i < _iCount; i++)
            {
                NvsSingle stNvs = new NvsSingle();

                //指针后移,读取下一个NvsSingle结构体
                IntPtr pNvs = (IntPtr)((UInt32)_pNvs + i * Marshal.SizeOf(stNvs));

                //读取NvsSingle结构体数据
                stNvs = (NvsSingle)Marshal.PtrToStructure(pNvs, typeof(NvsSingle));
                string strNvsIP     = Bytes2Str(stNvs.m_btNvsIP);
                string strNvsName   = Bytes2Str(stNvs.m_btNvsName);
                int    iNvsType     = stNvs.m_iNvsType;
                string strFactoryID = Bytes2Str(stNvs.m_btFactoryID);

                //创建匿名委托,以处理跨线程修改DataGridView控件属性
                MethodInvoker notify = delegate()
                {
                    //为DataGridView添加新行
                    dgvNVS.Rows.Add
                    (
                        new object[]
                    {
                        strNvsIP,
                        strNvsName,
                        iNvsType,
                        strFactoryID
                    }
                    );

                    //刷新DataGridView
                    dgvNVS.Invalidate();
                };

                //将匿名委托交给DataGridView控件处理
                dgvNVS.Invoke(notify);
            }
        }