16,472
社区成员
发帖
与我相关
我的任务
分享
#define OID_802_3_PERMANENT_ADDRESS 0x01010101
#define OID_802_3_CURRENT_ADDRESS 0x01010102
#define IOCTL_NDIS_QUERY_GLOBAL_STATS 0x00170002
void CNetCard::DoEnumNetcard()
{
//***********************
m_astrMacNum.RemoveAll();
m_nAdapterNum=0;
//***********************
CMyRegKey regKey;
TCHAR sz[512]={0};
CString strClassID(_T(""));
TCHAR szSubKey[256]={0};
DWORD dwIndex=0;
_tcscpy(sz,_T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkCards"));
if(regKey.RegOpen(HKEY_LOCAL_MACHINE,sz,TRUE) == ERROR_SUCCESS)
{
while(TRUE)
{
if(regKey.EnumSubKey(dwIndex,szSubKey,255) != ERROR_SUCCESS)
{
dwIndex++;
break;
}
dwIndex++;
if(_tcslen(szSubKey) <= 0) break;
CMyRegKey regSub;
_stprintf( sz,
_T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkCards\\%s"),
szSubKey);
if(regSub.RegOpen(HKEY_LOCAL_MACHINE,sz,TRUE) != ERROR_SUCCESS) break;
strClassID = _T("");
if(regSub.RegRead(_T("ServiceName"),strClassID) != ERROR_SUCCESS)
{
regSub.RegClose();
continue;
}
regSub.RegClose();
if(strClassID.GetLength() < 10) continue;
//_stprintf(sz,_T("%d\r\n%s\r\n%s"),dwIndex,szSubKey,strClassID);
//AfxMessageBox(sz);
HANDLE hHandle;
hHandle=CreateFile( _T("//./")+strClassID,
FILE_SHARE_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,//CREATE_ALWAYS,
0 ,
NULL);
if(hHandle == INVALID_HANDLE_VALUE)
{
continue ;
}
DWORD dw=0;
int iBuf = OID_802_3_PERMANENT_ADDRESS;
BYTE outBuf[256]={0};
TCHAR zz[32]={0};
if(DeviceIoControl(hHandle,
IOCTL_NDIS_QUERY_GLOBAL_STATS,
&iBuf,4,
outBuf,256,
&dw,
NULL))
{
_stprintf( zz,
_T("%02X%02X-%02X%02X-%02X%02X"),
outBuf[0],outBuf[1],outBuf[2],outBuf[3],outBuf[4],outBuf[5]);
m_astrMacNum.Add(zz);
m_nAdapterNum++;
}
CloseHandle(hHandle);
}
}
if(dwIndex > 0) regKey.RegClose();
//-- use bios --
if(m_nAdapterNum == 0)
{
NCB ncb;
UCHAR uRetCode;
LANA_ENUM lana_enum;
memset( &ncb, 0, sizeof(ncb) );
ncb.ncb_command = NCBENUM;
ncb.ncb_buffer = (unsigned char *) &lana_enum;
ncb.ncb_length = sizeof(lana_enum);
uRetCode = Netbios(&ncb);
if ( uRetCode == 0 )
{
m_nAdapterNum=lana_enum.length;
m_astrMacNum.SetSize(m_nAdapterNum,-1);
for ( int i=0; i<m_nAdapterNum; ++i)
{
m_astrMacNum[i]=GetMacOne(lana_enum.lana[i]);
}
}
else m_nAdapterNum=0;
}
}
page1
page2
//设置打印 <script language=javascript> function window.onload() { // -- advanced features factory.printing.SetMarginMeasure(2) // measure margins in inches factory.printing.SetPageRange(false, 1, 3) // need pages from 1 to 3 factory.printing.printer = "HP DeskJet 870C" factory.printing.copies = 2 factory.printing.collate = true factory.printing.paperSize = "A4" factory.printing.paperSource = "Manual feed" // -- basic features factory.printing.header = "居左显示&b居中显示&b居右显示页码,第&p页/共&P页" factory.printing.footer = "(自定义页脚)" factory.printing.portrait = false factory.printing.leftMargin = 0.75 factory.printing.topMargin = 1.5 factory.printing.rightMargin = 0.75 factory.printing.bottomMargin = 1.5 } function Print(frame) { factory.printing.Print(true, frame) // print with prompt } factory.printing.Print(false)">