MAC Address

Just starting out? Need help? Post your questions and find answers here.
Palpatine
User
User
Posts: 22
Joined: Wed May 05, 2004 7:43 am
Location: Rotterdam
Contact:

MAC Address

Post by Palpatine »

HI,

Is there a way to find out the mac address of the machine the app is running on?

Cheers,
Ron
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

the easiest way is to use the userlib SRGetInfo

get it here : http://www.purearea.net/pb/download/use ... ETINFO.zip

there are this commands in it :

SRGETCPUVendor
SRGETComputerName
SRGETDriveSerial
SRGETFolder
SRGETMACID <-------------
SRGETOnlinestatus
SRGETUsername
SRGetDriveFormat
SRGetDriveName
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Post by Rings »

arg did not work with 3.91, so an update is needed (if anyone wants a )
SPAMINATOR NR.1
Palpatine
User
User
Posts: 22
Joined: Wed May 05, 2004 7:43 am
Location: Rotterdam
Contact:

Post by Palpatine »

Rings wrote:arg did not work with 3.91
Just found that out to :-/

Cheers,
Ron
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

i do... or the names of the winapi's you used :-)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Post by Rings »

download new version at www.srings.de/downloads/srget
SPAMINATOR NR.1
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post by Shannara »

Does this return the real HD serial number or the changable volume number?
TerryHough
Enthusiast
Enthusiast
Posts: 781
Joined: Fri Apr 25, 2003 6:51 pm
Location: NC, USA
Contact:

Post by TerryHough »

Hmm... downloaded the new version, but I still don't get the Mac Address reported. Maybe it really isn't available on my Win98SE system to this function?
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Post by Rings »

sorry, i don't support any win89 OS.
But for all, i will release the source to this lib so anyone can take that what he need .
SPAMINATOR NR.1
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Post by ABBKlaus »

Try this one : (Tested under WinXP Pro / Win 2000 / Win98*)
* = tested by user

Code: Select all

; ABBKlaus Mon May 17, 2004 20:16
; http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iphlp/iphlp/getadaptersinfo.asp 
; with the help of IPHlpAPI.inc from the Powerbasic include-file for the structures 
; Microsoft isn´t quite a help here :-) 
; modified by PSW Wed Sep 06, 2006 07:49
; PB4.02 compatible since 29.05.2007 19:48

DHCPServerEnabled.s 

Structure IP_ADDR_STRING 
  pNext.l 
  IpAddress.b[16] 
  IpMask.b[16] 
  Context.l 
EndStructure 

Structure IP_ADAPTER_INFO 
Next.l 
ComboIndex.l 
AdapterName.b[260] ; MAX_ADAPTER_NAME_LENGTH + 4 
Description.b[132] ; MAX_ADAPTER_DESCRIPTION_LENGTH + 4 
AdressLength.l 
Address.b[8] ; MAX_ADAPTER_ADDRESS_LENGTH 
Index.l 
Type.l 
DhcpEnabled.l 
CurrentIpAddressPTR.l 
IpAddressList.IP_ADDR_STRING 
GatewayList.IP_ADDR_STRING 
DhcpServer.IP_ADDR_STRING 
HaveWins.l 
PrimaryWinsServer.IP_ADDR_STRING 
SecondaryWinsServer.IP_ADDR_STRING 
LeaseObtained.l 
LeaseExpires.l 
EndStructure 

length.l=0 
Result=GetAdaptersInfo_(0,@length) ; Get the length for Buffer 
If Result=#ERROR_BUFFER_OVERFLOW 
  *Buffer=AllocateMemory(length) 
  Result=GetAdaptersInfo_(*Buffer,@length) 
  If Result=#ERROR_SUCCESS 
    adapters=length/SizeOf(IP_ADAPTER_INFO) 
    For x=0 To adapters-1 
      Debug "AdapterNr : "+Str(x+1) 
      tempipinfo.IP_ADAPTER_INFO 
      For i=0 To SizeOf(IP_ADAPTER_INFO)-1 
        byte.b=PeekB(*Buffer+(x*640)+i) 
        PokeB(tempipinfo+i,byte) 
      Next 
      Debug "Adapter : "+PeekS(@tempipinfo\Description,-1,#PB_Ascii) 
      Debug "IP-Adress : "+PeekS(@tempipinfo\IpAddressList+4,-1,#PB_Ascii) 
      Debug "Gateway : "+PeekS(@tempipinfo\GatewayList+4,-1,#PB_Ascii) 
      
      Debug "P-Wins : "+PeekS(@tempipinfo\PrimaryWinsServer+4,-1,#PB_Ascii) 
      Debug "S-Wins : "+PeekS(@tempipinfo\SecondaryWinsServer+4,-1,#PB_Ascii) 
      
      
      ;Debug "DHCP-Server : "+PeekS(@tempipinfo\DhcpServer+4) 
      If PeekS(@tempipinfo\DhcpServer+4,-1,#PB_Ascii) = "255.255.255.255" 
        Debug "STATIC IP Configuration" 
       Else 
        Debug "DHCP Server Adress : " +PeekS(@tempipinfo\DhcpServer+4,-1,#PB_Ascii) 
      EndIf 
      
      
      mac$="" 
      For i=0 To 5 
        byte.b=PeekB(@tempipinfo\Address+i) 
        If byte>=0 
          mac$+RSet(Hex(byte),2,"0") 
        Else 
          mac$+RSet(Hex(byte+256),2,"0") 
        EndIf 
        If i<5 
          mac$+":" 
        EndIf 
      Next 
      Debug "MAC-Address "+mac$ 
    Next 
  Else 
    Debug "Error : "+Str(Result) 
  EndIf 
EndIf 

;----- Sample dump------------------------------------------------------------------
;AdapterNr : 1
;Adapter : ELSA Airlancer MC11 High Rate Wireless LAN PC Card - Paketplaner-Miniport
;IP-Adress : 192.168.1.115
;Gateway : 192.168.1.1
;MAC-Address 00:02:2D:3C:2E:73
;AdapterNr : 2
;Adapter : Realtek RTL8139-Familie-PCI-Fast Ethernet-NIC - Paketplaner-Miniport
;IP-Adress : 0.0.0.0
;Gateway : 
;MAC-Address 00:30:54:00:40:63
Last edited by ABBKlaus on Tue May 29, 2007 6:49 pm, edited 2 times in total.
TerryHough
Enthusiast
Enthusiast
Posts: 781
Joined: Fri Apr 25, 2003 6:51 pm
Location: NC, USA
Contact:

Post by TerryHough »

Thanks, it also works on my Win98SE successfully.
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

..

Post by NoahPhense »

ABBKlaus wrote:Try this one : (Tested under WinXP Pro)

Code: Select all

; http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iphlp/iphlp/getadaptersinfo.asp
; with the help of IPHlpAPI.inc from the Powerbasic include-file for the structures...
That kicks as$, I need that for my machine dependant encryption algorithm..

boyaa, thx!

- np
Post Reply