Highlighted
Absent Member.
Absent Member.
2636 views

[archive] Mac address

[Migrated content. Thread originally posted on 15 March 2006]

I have a request to get the mac address
for a application to make socket calls to a server

does anyone know where the address is stored
and how to get it.
0 Likes
14 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] Mac address

Elsewhere in the forum there is posted code that shows how to get the mac address of an adapter on Windows.

http://www.acucorp.com/support/supported/customer_forum/showthread.php?threadid=594

If you are not on Windows, you will have to find a counterpart to the api function used for your particular host.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Mac address

Thanks Gisle
that works like a charm.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Mac address

Hey all,

one question:
how do allocate the memory in windows when using acuthin?
@[display]:m$alloc produces an error.

CALL "@[display]:IpHlpAPI.DLL".
CALL "@[display]:GetAdaptersInfo" USING
BY VALUE AllocPtr
BY REFERENCE AllocSize.
CALL "M$ALLOC" USING AllocSize
AllocPtr.
CALL "@[display]:GetAdaptersInfo" USING
BY VALUE AllocPtr
BY REFERENCE AllocSize.


thx bli
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Mac address

I do not believe that the "display" side of thin client supports calling M$ALLOC. The thin client display side was architected to handle the display and printing aspects that an application needs but not manipulating the client machine memory.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Mac address

Dilbert is right.

However, you can use the LocalAlloc in the kernel32.dll from the Windows API.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Mac address

Problem: if LocalAlloc works right
strcpy copy?s no data to ip-adapter-info
any idea? or totally the wrong way?


CALL "@[display]:kernel.DLL".
CALL "@[display]:msvcrt.DLL".
CALL "@[display]:IpHlpAPI.DLL".

CALL "@[display]:GetAdaptersInfo" USING
BY VALUE AllocPtr
BY REFERENCE Allocsize.
INITIALIZE uFlag.
CALL "@[display]:LocalAlloc" USING
by value uFlag
by value AllocSize
giving AllocPtr.
CALL "@[display]:GetAdaptersInfo" USING
BY VALUE AllocPtr
BY REFERENCE AllocSize.

SET ENVIRONMENT "DLL-CONVENTION" TO "0"
CALL "@[display]:strcpy" USING
BY reference ip-adapter-info
BY value AllocPtr.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Mac address

Two issues:

First, use kernel32, not kernel.

Second, strcpy is to copy a string, not a struct (group in COBOL), so you should use memcpy instead, strcpy will terminate on the first occurence of ascii 0 in the data. I believe there are quite a few of those in this.

May be this was a bad idea.

Perhaps you should use malloc(), free() and memcpy() from the VC runtime library instead. After all, you already have msvcrt loaded so...
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Mac address

It is kernel32.
Your are right with strcpy, i knew that but i didn?t saw the coherence.
Now i use memcpy and everything works fine.

Thank?s for help.

Andreas
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Mac address

Excellent!

Perhaps you would care to post a little demo, would be nice to show how to accomplish this in a TC environment, alternatively also as a guide on how to use remote DLLs.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Mac address

be careful, no error handling
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Mac address

Thanks, your contribution to the forum is appreciated!
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.