MAC Address
MAC Address
HI,
Is there a way to find out the mac address of the machine the app is running on?
Cheers,
Ron
Is there a way to find out the mac address of the machine the app is running on?
Cheers,
Ron
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
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
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
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... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
-
- Enthusiast
- Posts: 781
- Joined: Fri Apr 25, 2003 6:51 pm
- Location: NC, USA
- Contact:
Try this one : (Tested under WinXP Pro / Win 2000 / Win98*)
* = tested by user
* = 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.
-
- Enthusiast
- Posts: 781
- Joined: Fri Apr 25, 2003 6:51 pm
- Location: NC, USA
- Contact:
- NoahPhense
- Addict
- Posts: 1999
- Joined: Thu Oct 16, 2003 8:30 pm
- Location: North Florida
..
That kicks as$, I need that for my machine dependant encryption algorithm..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...
boyaa, thx!
- np