Jump to content
  • Advertisement
Sign in to follow this  
Super Sheep

launching app with DirectPlay

This topic is 4419 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there. I was working in a project without directplay API, a program that launchs a game at a certain time. Just like MSN Mensager does(you can start a game GUID registered without the need to set configurations like the host's IP). But that games aren't launched by command-line(as far as I know), but somehow the parametters are passed. I'm a newbie at DX, all I wanna do is to call the game and order it to host or to connect to a IP. Someone please tell me how, or show me examples. I defined the GUID to be called and initializated the DX thing, but nothing. All that tutorials arroud act as if the programmer couldn't call the game from the outside, with separed executables. But msn, all seeing eye, gamespy, xfire and kali does that all the time... how?... Thanks. And sory for my bad english.

Share this post


Link to post
Share on other sites
Advertisement
If you're trying to run external programs and you're using windows(which I take it you are with DirectPlay) then you could try ShellExecute. However the programs you're calling MUST allow you to pass arguments through the command line(in the case of ShellExecute, that's lpParameters).

Share this post


Link to post
Share on other sites
Quote:
Original post by Scet
If you're trying to run external programs and you're using windows(which I take it you are with DirectPlay) then you could try ShellExecute. However the programs you're calling MUST allow you to pass arguments through the command line(in the case of ShellExecute, that's lpParameters).


But I dunno what's the parameter. I wonder if someone from this directx forum knows it. It may be a padronized DIRECTPLAY parameter, if it's passed that way, becouse if you get an old msn version it'll still see the most modern games and launch them without trouble...

Share this post


Link to post
Share on other sites
If i understand you right you want to order a DirectPlay-powered game to connect to a server (of which you pass the IP).

If the game is correctly set up you use the IID_IDirectPlayLobby3A class. Once you have acquired all the needed objects via enumeration you start the game like this:


HRESULT RunApplication( LPDIRECTPLAYLOBBY3A lpDPlayLobby, LPGUID lpguidApplication, LPGUID lpguidInstance, LPGUID lpguidServiceProvider,
LPVOID lpAddress, DWORD dwAddressSize, LPSTR lpszSessionName, LPSTR lpszPlayerName, BOOL bHostSession, DWORD dwMaxPlayers )
{

DPSESSIONDESC2 sessionInfo;

DPNAME playerName;

DPLCONNECTION connectInfo;

HRESULT hr;


if ( lpDPlayLobby == NULL )
{
return DPERR_NOINTERFACE;
}

// fill out session description
ZeroMemory( &sessionInfo, sizeof( DPSESSIONDESC2 ) );
sessionInfo.dwSize = sizeof( DPSESSIONDESC2 ); // Size of structure
sessionInfo.dwFlags = 0; // DPSESSION_xxx flags

sessionInfo.guidInstance = *lpguidInstance; // ID for the session instance
sessionInfo.guidApplication = *lpguidApplication;// GUID of the DirectPlay application.
sessionInfo.dwMaxPlayers = dwMaxPlayers; // Maximum # players allowed in session
sessionInfo.dwCurrentPlayers = 0; // Current # players in session (read only)
sessionInfo.lpszSessionNameA = lpszSessionName; // ANSI name of the session
sessionInfo.lpszPasswordA = NULL; // ANSI password of the session (optional)
sessionInfo.dwReserved1 = 0; // Reserved for future MS use.
sessionInfo.dwReserved2 = 0;
sessionInfo.dwUser1 = 0; // For use by the application
sessionInfo.dwUser2 = 0;
sessionInfo.dwUser3 = 0;
sessionInfo.dwUser4 = 0;

// fill out player name
ZeroMemory( &playerName, sizeof( DPNAME ) );
playerName.dwSize = sizeof( DPNAME ); // Size of structure
playerName.dwFlags = 0; // Not used. Must be zero.
playerName.lpszShortNameA = lpszPlayerName; // ANSI short or friendly name
playerName.lpszLongNameA = lpszPlayerName; // ANSI long or formal name

// fill out connection description
ZeroMemory( &connectInfo, sizeof( DPLCONNECTION ) );
connectInfo.dwSize = sizeof( DPLCONNECTION ); // Size of this structure
if ( bHostSession )
{
connectInfo.dwFlags = DPLCONNECTION_CREATESESSION; // Create a new session
}
else
{
connectInfo.dwFlags = DPLCONNECTION_JOINSESSION; // Join existing session
}
connectInfo.lpSessionDesc = &sessionInfo; // Pointer to session desc to use on connect
connectInfo.lpPlayerName = &playerName; // Pointer to Player name structure
connectInfo.guidSP = *lpguidServiceProvider; // GUID of the DPlay SP to use
connectInfo.lpAddress = lpAddress; // Address for service provider
connectInfo.dwAddressSize = dwAddressSize; // Size of address data

// launch and connect the game
hr = lpDPlayLobby->RunApplication( 0, &dwDPlayAppID, &connectInfo, hWaitEvent );

return hr;

}




This is a snippet of a old matchmaking app that started DirectPlay and non DirectPlay games. It may require some tweaking and esp. acquiring the correct devices to get going.

The guid of the service provider has to be acquired from enumerating the connection types (filter out the tcp/ip one).

Edit: Reformatted snippet due to fugly tabs inside. Tabs are devils sprout!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!