Tuesday, February 21, 2012

How to play *.XM / *.MOD files in VB.NET (Using reflection)

Note: This article was originally posted by me at http://www.gamehacking.com 2 years ago,and you can see the original post here for the details.

If you are not  already aware that i am too a proud member of  gamehacking.com (a mod. actually) and lots of guys asking there this same question that "How to play *.XM / *.MOD files in VB.NET " .

You might ask what's the problem just use any free audio library to do this,you are correct.But the actual problem was that guys want everything inside a single executable file without using a packer even the *.DLL files itself and to do this we have to use a feature called reflection.

So when i found a solution i code a module so anybody can use *xm/*mod easily without need to understand whole reflection thing.

So here's my module..........

(*.vb module with a demo *.exe)

(*.vb module only)

-the dll and music will be in resource so you don't need pack it again.
-size is less (atleast compare to a wav file)
-And it's in the module so you don't need to understand the code but that would be recommended.

how to use:-

1. Add my module to your project(right click on solution explorer and click add existing item).
2. Add 3 files bass.dll , bass.net.dll , and the music you wanna play,in the project resource.

download bass.dll
Download bass24.zip

download Bass.Net.dll

3. GO and register for free to bass.net.dll otherwise it will show a trial version message.

register here    BASS.NET : Registration


you need to call this function before any other functions of my module.

note:- if you not registered then put anything in both string place,it will run with a trial version message.

dim status = music(my.resource.filename_of_xm_mod,"registered email-id","registration_code")

now there are 4 functions call any where you need


private sub button1_click()

    if status=0 then
        exit sub
    end if
End sub


  1. Hi
    my project is fine and i did what ever you did say but when i start and press the button nothing is happening and i hear nothing so what should i do

  2. plz visit gamehacking.com to find a sample code with executable file.


Like this post? let me know just leave a comment..