Click here to Skip to main content
15,915,789 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Extension DLL trouble Pin
Daniel Hellsson22-Jan-02 3:55
Daniel Hellsson22-Jan-02 3:55 
GeneralRe: Extension DLL trouble Pin
Roger Allen22-Jan-02 4:12
Roger Allen22-Jan-02 4:12 
GeneralRe: Extension DLL trouble Pin
Daniel Hellsson22-Jan-02 4:21
Daniel Hellsson22-Jan-02 4:21 
GeneralRe: Extension DLL trouble Pin
Roger Allen22-Jan-02 5:02
Roger Allen22-Jan-02 5:02 
GeneralMulticast with UDP Pin
Grit21-Jan-02 22:31
Grit21-Jan-02 22:31 
GeneralRe: Multicast with UDP Pin
markkuk21-Jan-02 22:41
markkuk21-Jan-02 22:41 
GeneralIMac address Pin
ZAZA21-Jan-02 22:23
ZAZA21-Jan-02 22:23 
GeneralRe: IMac address Pin
Michael A. Barnhart22-Jan-02 2:23
Michael A. Barnhart22-Jan-02 2:23 
This is what I have been using on NT4 machines.

If you have say IIS running this fails due to not allowing the lan adapter to reset.

// requires Netapi32.lib for linking
CString GetTheMacAddress(int adapter_num)
{
CString mac_addr;
TRY // if the request has an invalid port it fails. Need to look for option for error test
{
// Reset the LAN adapter so that we can begin querying it
NCB Ncb; // requires Nb30.h header
memset(&Ncb, 0, sizeof(Ncb));
Ncb.ncb_command = NCBRESET;
Ncb.ncb_lana_num = adapter_num;
if (Netbios(&Ncb) != NRC_GOODRET)
{
mac_addr = "BAD (NCBRESET): ";
mac_addr += Ncb.ncb_retcode;
goto fail_mac;
}

// Prepare to get the adapter status block
memset(&Ncb,(char)0,sizeof(Ncb));
Ncb.ncb_command = NCBASTAT;
Ncb.ncb_lana_num = adapter_num;
strcpy((char *) Ncb.ncb_callname, "*");
struct ASTAT
{
ADAPTER_STATUS adapt;
NAME_BUFFER NameBuff[30];
} Adapter;
memset(&Adapter,(char)0,sizeof(Adapter));
Ncb.ncb_buffer = (unsigned char *)&Adapter;
Ncb.ncb_length = sizeof(Adapter);

// Get the adapter's info and, if this works, return it in standard,
// colon-delimited form.
if (Netbios(&Ncb) == 0)
{
mac_addr.Format("%02X%02X%02X%02X%02X%02X",
int (Adapter.adapt.adapter_address[0]),
int (Adapter.adapt.adapter_address[1]),
int (Adapter.adapt.adapter_address[2]),
int (Adapter.adapt.adapter_address[3]),
int (Adapter.adapt.adapter_address[4]),
int (Adapter.adapt.adapter_address[5]));
}
else
{
mac_addr = "BAD (NCBASTAT): ";
mac_addr += Ncb.ncb_retcode;
}
}
CATCH_ALL(e)
{
mac_addr = "BAD";
}
END_CATCH_ALL
fail_mac:
if(mac_addr.Left(3).Compare("BAD")==0)
{
mac_addr = GetTheComputerName();
mac_addr+="xxxxxxxxxxxx";
mac_addr = mac_addr.Left(12);
}
else if(mac_addr.Left(12).Compare("000000000000")==0)
{
mac_addr = GetTheComputerName();
mac_addr+="xxxxxxxxxxxx";
mac_addr = mac_addr.Left(12);
}
return mac_addr;
}
GeneralWindows Sockets Pin
ananth_rs21-Jan-02 21:27
ananth_rs21-Jan-02 21:27 
GeneralRe: Windows Sockets Pin
Joaquín M López Muñoz21-Jan-02 21:41
Joaquín M López Muñoz21-Jan-02 21:41 
GeneralRe: Windows Sockets Pin
ananth_rs22-Jan-02 5:55
ananth_rs22-Jan-02 5:55 
GeneralRe: Windows Sockets Pin
Joaquín M López Muñoz22-Jan-02 8:50
Joaquín M López Muñoz22-Jan-02 8:50 
GeneralXML newcomer Pin
Braulio Dez21-Jan-02 20:53
Braulio Dez21-Jan-02 20:53 
GeneralRe: XML newcomer Pin
Michael A. Barnhart22-Jan-02 2:35
Michael A. Barnhart22-Jan-02 2:35 
GeneralRe: XML newcomer Pin
Not Active22-Jan-02 3:50
mentorNot Active22-Jan-02 3:50 
GeneralRe: XML newcomer Pin
Michael Dunn22-Jan-02 7:55
sitebuilderMichael Dunn22-Jan-02 7:55 
GeneralDisplaying stock quote in a C++ app Pin
SAK21-Jan-02 20:10
SAK21-Jan-02 20:10 
QuestionATL and enumerated values? Pin
Phil F21-Jan-02 19:53
Phil F21-Jan-02 19:53 
AnswerRe: ATL and enumerated values? Pin
Michael P Butler21-Jan-02 22:15
Michael P Butler21-Jan-02 22:15 
GeneralRe: ATL and enumerated values? Pin
Phil F22-Jan-02 6:34
Phil F22-Jan-02 6:34 
Generalnew versus VirtualAlloc Pin
alex.barylski21-Jan-02 19:02
alex.barylski21-Jan-02 19:02 
GeneralRe: new versus VirtualAlloc Pin
Phil F21-Jan-02 20:03
Phil F21-Jan-02 20:03 
GeneralRe: new versus VirtualAlloc Pin
alex.barylski22-Jan-02 10:18
alex.barylski22-Jan-02 10:18 
GeneralMCIWndCreate and Win2k Pin
21-Jan-02 13:15
suss21-Jan-02 13:15 
GeneralProblem subclassing CHeaderCtrl OnPaint Pin
Lea Johnson21-Jan-02 13:06
Lea Johnson21-Jan-02 13:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.