LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Obtaining MAC address

I'm working on the application which will be "locked" to speciffic HW due to security reasons.
I need a way to obtain the ethernet MAC address of the machine this application is installed on. (Also Hard Disk serial and CPU serial).
I have a solution working pretty good based on calling ipconfig /all which I'm redirecting to a file. Later I scan this file, save the info I need into a char variable and delete the file. The code to create the file looks like:

system ("cmd /C ipconfig /all>mac.mac");

I'm using, similarly, dir to obtain Volume number of the HD. (I would like to have the manufacturer number but I don't have solution).

The problems are:
1. Cmd.exe prompts shortly a DOS window on the screen
2. The file, even rapidly created and deleted is still a trace what the application is doing
3. Windows Vista does not allow such things like file creation, unless you manualy specify whole application folder with administrative privileges, or each time you start the application "as administrator"

Can I use ipconfig /all | pipe (redirect to a phisical memory range) to do the same thing. I need to avoid file creation. Can you give me some example on how to do that. How to define the memory, DOS script and how can I scan that phisical memory later to obtain the MAC.
I've red many different solutions based on .NET, WMA, vbs scripts, LabView solutions. Is there any way to use them with CVI. Any program code or description will be appretiated.

Thanks
0 Kudos
Message 1 of 19
(6,573 Views)
You can use Netbios in the Windows SDK as in the attached example.
Message 2 of 19
(6,563 Views)

You can use the Windows SDK GetVolumeInformation function to read the disk Volume name and serial number, as in the attached example.

 

Message 3 of 19
(6,554 Views)
Thank you very much Al S Smiley Very Happy

It looks very promissing in the first look. I'll give it a try soon.
Will post the results later.
0 Kudos
Message 4 of 19
(6,551 Views)
The example "GetVolume" is working perfectSmiley Very Happy
I've tried it in 4 different PC's and it works even with SATA hard drives.
The only thing was that the representation of the HD was decimal (example - 539707338) instead of hex. (202B47CA) but I figure it out when I saw the code.Smiley Happy

However I can not build the "MAC" project because I do not have NETAPI32.lib in my installation. I have the NETAPI32.DLL in my \\system32 folder. I used a shareware tool to build the LIB from DLL but I've got an error whwn I try to compile the project:

"Unrecoverable Internal Error at 001B:1021501D.
LabWindows/CVI will be aborted"

I'm sure that this is because of the way I got this library in the project.

Where can I download NETAPI32.LIB or how can I create it?
0 Kudos
Message 5 of 19
(6,536 Views)
OK, I didn't know that the Windows SDK was not fully installed on my machine. After I install it I can compile the project.

But I still did not get the MAC address.

I get an error:

ERROR: The NCBRESET return code is: 0x23
ERROR: The NCBASTAT return code is: 0x23

What am I missing ?Smiley Sad

Message Edited by DVD_Boost on 01-09-2007 01:53 PM

0 Kudos
Message 6 of 19
(6,532 Views)

Error 0x23, defined in nb30.h, is NRC_BRIDGE: The ncb_lana_num member did not specify a valid network number.

ncb_lana_num
Specifies the LAN adapter number. This zero-based number corresponds to a particular transport provider using a particular LAN adapter board.

The sample program sets ncb_lana_num = 0, which should be the first LAN adapter or Network Interface Card (NIC).  You could try changing it to 1.

What version of Windows are you running?

What Network software are you running?  The Client for Microsoft Networking?

How many LAN adapters do you have in the PC?

Do you get the same results on other PCs?

0 Kudos
Message 7 of 19
(6,520 Views)
I tried changing ncb_lana_num from 0 to 5 but still the same.

I'm running Windows XP Pro (eng) on both of the machines which get error (the other one has an error code 0x3F).

I'm using Client for Microsoft Networking and TCP/IP protocol.

There is two LAN adapters on the first PC (one wireless).

The one PC with Vista installed is working perfect. (strange).

Do I have to install NetBEUI protokol ? (I did with no difference).
0 Kudos
Message 8 of 19
(6,494 Views)
Try this update which uses the NCBENUM command to get an enumerated list of valid LANA numbers before proceding.
0 Kudos
Message 9 of 19
(6,393 Views)
Still exactly the same error messages on both PC's.

Is it possible that I did not activate correctly NetBIOS?

I used:
Network connections-My current connection-Properties-TCP/IP-Advanced-Wins-Enable NetBIOS...?
Is that correct?

What am I missing?

Message Edited by DVD_Boost on 01-09-2007 04:26 PM

0 Kudos
Message 10 of 19
(6,393 Views)