Detecting MAC

Blitz3D Forums/Blitz3D Programming/Detecting MAC

Baystep Productions(Posted 2006) [#1]
Not MAC as in Macintosh, but MAC as in your NIC's MAC ADDRESS.

For those that aren't sure what that is. It is the special serial type value given to each network card when its made. Its different for every computer and can never be changed without actualy changing the whole card.

Is there a way to find this and record it in Blitz?


Boiled Sweets(Posted 2006) [#2]
You could probably do this by creating a decls for the netapi32.dll and call the Netbios function.


smilertoo(Posted 2006) [#3]
I hope youre not planning to use this as copy protection, ive gone through 2 motherboards in a year that would break any such protection.


Red Ocktober(Posted 2006) [#4]
it's not that difficult... well, at least the solution i came up with isn't anyways...

it's a lil bit of a hack, but effective enough... a simple, almost too obvious method for retreiving results of anything that a dos command can obtain...

all it does is write a batch file to automate the dos ipconfig command, and pipes the output to a file... then that file is read in... the MAC address should appear...

copy and paste into the ide and run it...

; -------------------------------- reserve some space... i don't think i'll need more 
;                                  than 33 lines of text
Dim myInfo$(33)

;--------------------------------- nothing really, just a pointer to the home dir
;
HomeDir$="c:\progra~1\blitz3d\"

; -------------------------------- set up a window
;
Graphics 640,480,16 


; -------------------------------- first we're gonna build a bat. file for execution
;                                  which will pipe the dos command ipconfig to a file
;
myInfoFile=WriteFile(homeDir+"GetMyInfo.Bat")
a$="ipconfig.exe/all>"+ homeDir + "myinfo.txt"
WriteLine(myInfoFile,A$)
CloseFile(myInfoFile)

; -------------------------------- ok, that done, we're ready to exec it
;
Print ""
Print "   dos bat file ready... press any key to run"
WaitKey()


ExecFile(HomeDir+"GetMyInfo.bat")
Cls
Print "   info file printed... press any key to read"
WaitKey()


;Print sysDir$ + "ipconfig/all > " + homeDir + "myinfo.txt"


; -------------------------------- read in the file created and print out the info
;
Cls
info=ReadFile("c:\progra~1\Blitz3d\myinfo.txt")
While Not Eof(info)
 myInfo$(x)=ReadLine(info)
 Print myinfo$(x)
Wend
Print ""
Print "   info file deleted... "
Print ""
Print "   you can write your own parsing code to get the info you need"
Print ""
Print "   press any key to end"
Print ""
Print ""
Print ""
Print "       ( another lil bit of madness from the mind of Mike Hense )"

DeleteFile(homeDir+"GetMyInfo.Bat")

WaitKey()

End

i think that there's a way to have the dos command execute quietly (no popup window)... and i'm sure that there are other options to the command which you could use...

also, you'll have to come up with your own parsing routine to extract the mac address (the physical address line)... sorry :) it should be easy though... just test each line for the string "Physical Address" and go o from there...

@ JD...
a few software licenses are dependent on this sorta stuff... i know this can be a bit of a pain, especiallywhen your hardware changes, but what's wrong with simply contacting the vendor, and telling em that you've changed machines... usually they'll give you a new key... some of em allow for two keys anyway...

i think PaceMaker uses something similar...

--Mike


Baystep Productions(Posted 2006) [#5]
Server banning for games/apps


Red Ocktober(Posted 2006) [#6]
hey PCD... was the solution above what you were looking for...

--Mike


Baystep Productions(Posted 2006) [#7]
errr... I haven't really bothered righting up a parser for it. It did read out, but I found other bugs and stuff with my main code I've been working out. I tell you when I get to it.


Red Ocktober(Posted 2006) [#8]
i just asked as i may be using this myself, so i was a lil curious about your progress as far as this went...

i may have a parser up in the next few days... also busy here with other coding issues myself... the parser would be a trivial bit of coding, only needing to check the first couple of characters of each line for the string "Physical Address", then, if found, retrieving the next 12 alphanumeric chars, discarding everything else...

if i do finish the code i'll post it... keep me updated on your progress as well will ya...

thx

--Mike


asdfasdf(Posted 2006) [#9]
I know how to make a bat file run silently. 3 files are required. It might make some anti-virus programs go crazy though.

fileA.bat
wscript.exe "C:\path\to\fileB.vbs" "FileC.bat"


fileB.vbs
CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False


fileC.bat
Your BAT code here



t3K|Mac(Posted 2006) [#10]
removed


Space_guy(Posted 2006) [#11]
Seems alil overkill to still use a .bat file if your going to launch it using wscript
Its pretty simple to make the vbs file detect all the computer info you need.

go here for alot of examples
http://www.microsoft.com/technet/scriptcenter/scripts/default.mspx


Red Ocktober(Posted 2006) [#12]
what's 'overkill' about it... simple to create a bat text file in blitz... simple to run it... simple to retrieve the info you need from it... simple to get rid of it when it's all done...

as opposed to playing around with visual basic, scripting hosts, etc...

this approach assumes nothing about the clients machine the app is running on... it's simple... and it'll work 100% of the time...

but i'm sure there are other methods equally as usefull...

--Mike


Space_guy(Posted 2006) [#13]
Well. its just that vbs scripts are pretty easy. so one would have one less file to bother about.
Anyway its good to have atleast one way to do it ey? :)