Bonjour,

J'aimerais que ce programme écrive ma MAC-ADDRESS dans un certain fichier "text.txt" voici comme j'ai procéder :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
 
#include "stdafx.h"
#include <Windows.h>
#include <Iphlpapi.h>
#include <Assert.h>
#include <iostream>
#include <string>
#include <fstream>
#pragma comment(lib, "iphlpapi.lib")
 
 
using namespace std;
// 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]);
 
    ofstream fichier("test.txt", ios::out | ios::trunc);  // ouverture en écriture avec effacement du fichier ouvert
 
        if(fichier)
        {
 
                fichier << "Mac Address : " <<.......; //Je ne trouve pas la variable qui contient ma MAC-ADDRESS.
 
                fichier.close();
        }
        else
                cerr << "Impossible d'ouvrir le fichier !" << endl;
 
 
 
}
 
// Fetches the MAC address and prints it
static void GetMACaddress(void)
{
	IP_ADAPTER_INFO AdapterInfo[16];			// Allocate information for up to 16 NICs
	DWORD dwBufLen = sizeof(AdapterInfo);		// Save the memory size of buffer
 
	DWORD dwStatus = GetAdaptersInfo(			// Call GetAdapterInfo
		AdapterInfo,							// [out] buffer to receive data
		&dwBufLen);								// [in] size of receive data buffer
	assert(dwStatus == ERROR_SUCCESS);			// Verify return value is valid, no buffer overflow
 
	PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo;// Contains pointer to current adapter info
	do {
		PrintMACaddress(pAdapterInfo->Address);	// Print MAC address
		pAdapterInfo = pAdapterInfo->Next;		// Progress through linked list
	}
	while(pAdapterInfo);						// Terminate if last adapter
}
 
int _tmain(int argc, _TCHAR* argv[])
{
	GetMACaddress();// Obtain MAC address of adapters
 
 
 
	return 0;
}

Je préfère vous dire que je ne sais pas programmer en C++ et que j'ai trouvé ce code sur internet, pour les quelques lignes qui devraient écrire la MAC-ADDRESS dans un fichier, je les ai aussi trouvée sur internet. Donc je ne connais pas .

Premièrement je sais pas si ces lignes doivent se trouver la, si elles sont bien écrites car pour l'instant quand je lance le programme, le fichier test.txt ne contient rien.

Merci d'avance.

A+ .