DirectX:DirectPlay:Tutorials:VB:DX7:Initialization

From GPWiki
Jump to: navigation, search
SpiderWeb-40px.png   This article is deprecated. The techniques, code or technology may be out-of-date or superseded.
You can help out by updating it or linking to a page with newer information.


So simple, even your dog could do it! 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!

Const AppGuid = "{64823540-E39A-11D3-9651-0080C8E4028D}"

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.)