ATTENTION READERS! Lucky's VB Gaming Site is no longer active. For updated game programming information and tutorials, please visit The Game Programming Wiki!
Initialization
So simple, even your dog could do it! (Coincidentally, I've been told by many people that their dog's name is "Lucky"... heh)
All we really need to do here is create a new DirectPlay instance by calling the DirectX7.DirectPlayCreate method:
Dim dx As New DirectX7
Dim dp As DirectPlay4
Set dp = dx.DirectPlayCreate("")
DirectPlay is initialized! There are some other things we could discuss here as well, most notably, the creation of a Globally
Unique Identifier or GUID. The GUID will be needed later to when searching for, and creating, sessions of our game. Each game that
uses DirectPlay must be able to differentiate between other kinds of DirectPlay games so that they do not inadvertently connect to alien
sessions and cause errors. The GUID is a string guaranteed to be unique, and we can therefore utilize its uniqueness to discriminate
between sessions created by unique games. Example: You don't want to connect to a game of StarCraft when you're trying to play
Unreal Tourney, do you? Guaranteed blue screen of death :)
This is the GUID used in NetPONG (so.. don't use it in your game!). To create a unique GUID for yourself, have a look in the DirectX
SDK directory /samples/Multimedia/VBSamples/DXMisc/bin for "VBGUIDGEN.EXE"... clickety-click on it and you've got yourself a
brand-spanking new GUID. Congratulations, it's a boy.
Now, cram that big fat string into a constant (as above) and forget about it for a while :)
Continue along the road to DirectPlay enlightenment. Read the Enumeration of Service Providers tutorial. (click here to download this
tutorial's source code)