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

C / C++ / MFC

 
GeneralRe: Question about memory locations. Pin
Lord Kixdemp1-Jul-06 17:00
Lord Kixdemp1-Jul-06 17:00 
QuestionApplication failed to initialize using Detours [modified] Pin
Sam Hobbs24-Jun-06 15:21
Sam Hobbs24-Jun-06 15:21 
QuestionIE Toolbar or BHO Images and Temp Folder Location Pin
Ranjan Banerji24-Jun-06 15:11
Ranjan Banerji24-Jun-06 15:11 
AnswerRe: IE Toolbar or BHO Images and Temp Folder Location Pin
Michael Dunn24-Jun-06 15:29
sitebuilderMichael Dunn24-Jun-06 15:29 
GeneralRe: IE Toolbar or BHO Images and Temp Folder Location Pin
Ranjan Banerji25-Jun-06 5:51
Ranjan Banerji25-Jun-06 5:51 
GeneralRe: IE Toolbar or BHO Images and Temp Folder Location Pin
Michael Dunn25-Jun-06 7:55
sitebuilderMichael Dunn25-Jun-06 7:55 
GeneralRe: IE Toolbar or BHO Images and Temp Folder Location Pin
Ranjan Banerji25-Jun-06 8:01
Ranjan Banerji25-Jun-06 8:01 
QuestionUnhandled Exception when outputting strings [modified] Pin
capricious_00124-Jun-06 12:50
capricious_00124-Jun-06 12:50 
AnswerRe: Unhandled Exception when outputting strings Pin
Michael Dunn24-Jun-06 13:00
sitebuilderMichael Dunn24-Jun-06 13:00 
GeneralRe: Unhandled Exception when outputting strings Pin
capricious_00124-Jun-06 13:16
capricious_00124-Jun-06 13:16 
AnswerRe: Unhandled Exception when outputting strings Pin
Jun Du24-Jun-06 13:22
Jun Du24-Jun-06 13:22 
AnswerRe: Unhandled Exception when outputting strings [modified] Pin
Sam Hobbs24-Jun-06 15:35
Sam Hobbs24-Jun-06 15:35 
AnswerRe: Unhandled Exception when outputting strings Pin
Stephen Hewitt24-Jun-06 17:41
Stephen Hewitt24-Jun-06 17:41 
QuestionRe: Unhandled Exception when outputting strings Pin
capricious_00125-Jun-06 2:10
capricious_00125-Jun-06 2:10 
Questionasp help Pin
khasiguy24-Jun-06 9:42
khasiguy24-Jun-06 9:42 
AnswerRe: asp help Pin
Michael Dunn24-Jun-06 12:29
sitebuilderMichael Dunn24-Jun-06 12:29 
QuestionGet MAC help Pin
borono24-Jun-06 9:42
borono24-Jun-06 9:42 
hey, I need some help passing a char. When the app. starts, it has an assertion failure, because the NetWkstaTransportEnum() function fails when I pass the netbios name of a server on my network to it. If I use NULL, it outputs the local MAC address.

// GetMACNETBIOS.cpp : Defines the entry point for the console application.

#include "stdafx.h"
#include <Windows.h>
#include <lm.h>
#include <assert.h>


#pragma comment(lib, "Netapi32.lib")

// Prints the MAC address stored in a 6 byte array to stdout
static void PrintMACaddress(unsigned char MACData[])
{
	printf("MAC Address: %02X-%02X-%02X-%02X-%02X-%02X\n", 
		MACData[0], MACData[1], MACData[2], MACData[3], MACData[4], MACData[5]);
}

// Fetches the MAC address and prints it
static void GetMACaddress(void)
{
	unsigned char MACData[8];						// Allocate data structure for MAC (6 bytes needed)

	WKSTA_TRANSPORT_INFO_0 *pwkti;					// Allocate data structure for Netbios
	DWORD dwEntriesRead;
	DWORD dwTotalEntries;
	BYTE *pbBuffer;
    
	//MessageBox(NULL,netbios,0,0);

	// Get MAC address via NetBios's enumerate function
	NET_API_STATUS dwStatus = NetWkstaTransportEnum(
		"\\server",					// [in]  server name :: <-- fails here, if NULL, returns local MAC OK
		0,							// [in]  data structure to return
		&pbBuffer,					// [out] pointer to buffer
		MAX_PREFERRED_LENGTH,		// [in]  maximum length
		&dwEntriesRead,				// [out] counter of elements actually enumerated
		&dwTotalEntries,			// [out] total number of elements that could be enumerated
		NULL);						// [in/out] resume handle

	assert(dwStatus == NERR_Success);

	pwkti = (WKSTA_TRANSPORT_INFO_0 *)pbBuffer;		// type cast the buffer

	for(DWORD i=1; i< dwEntriesRead; i++)			// first address is 00000000, skip it
	{												// enumerate MACs and print
		swscanf((wchar_t *)pwkti[i].wkti0_transport_address, L"%2hx%2hx%2hx%2hx%2hx%2hx", 
			&MACData[0], &MACData[1], &MACData[2], &MACData[3], &MACData[4], &MACData[5]);
		PrintMACaddress(MACData);
	}

	// Release pbBuffer allocated by above function
	dwStatus = NetApiBufferFree(pbBuffer);
	assert(dwStatus == NERR_Success);
}

int _tmain(int argc, _TCHAR* argv[])
{

	GetMACaddress();							// Obtain MAC address of adapters

	return 0;
}


I think I may need to do a unicode conversion, but am not sure how. It may not even be that, as well. So, I need help passing the netbios name of a remote server (e.g. \\SERVER001), to the NetWkstaTransportEnum() function. All help is very much appreciated, thanks in advance.

salut
AnswerRe: Get MAC help Pin
Michael Dunn24-Jun-06 12:32
sitebuilderMichael Dunn24-Jun-06 12:32 
GeneralRe: Get MAC help Pin
borono24-Jun-06 15:00
borono24-Jun-06 15:00 
GeneralRe: Get MAC help Pin
Michael Dunn24-Jun-06 15:32
sitebuilderMichael Dunn24-Jun-06 15:32 
GeneralRe: Get MAC help Pin
borono24-Jun-06 15:54
borono24-Jun-06 15:54 
QuestionBeautify XML Pin
Ed K24-Jun-06 7:33
Ed K24-Jun-06 7:33 
QuestionHELP! * Accurate Text Extent needing * Pin
Furno Gianluca24-Jun-06 7:09
Furno Gianluca24-Jun-06 7:09 
QuestionC# and C++ and COM variables Pin
Dave_Roach24-Jun-06 6:35
Dave_Roach24-Jun-06 6:35 
QuestionCWnd::OnEnable and CWnd display Pin
Gilles0660024-Jun-06 5:52
Gilles0660024-Jun-06 5:52 

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.