Learning DirectPlay

Started by
5 comments, last by Ratman 24 years ago
Im trying to learn directplay with the tutorial here on gamedev, and the directx helpfile. But the code is already not working (compiling). heres whats wrong: if(CoCreateInstance(CLSID_DirectPlay, NULL, CLSCTX_INPROC_SERVER, IID_IDirectPlay3A ,(LPVOID*)&lpdp ) != S_OK) { ErrorMessage("Error creating Directplay object"); CoUninitialize(); return; } // creating lobby object DirectPlayLobbyCreate(NULL, &lpdp, NULL, NULL, 0); // get new interface of lobby lpdp->QueryInterface(LPDIRECTPLAYLOBBY2A, (LPVOID *)&lpdplobby); //error C2275: ''LPDIRECTPLAYLOBBY2'' : illegal use of this type as an expression lpdp->Release(); I get errors with QueryInterface... any ideas? thanks dave ratti
Advertisement
<disclaimer>I have never used DirectPlay.</disclaimer>

quote:Original post by Ratman

// get new interface of lobby

lpdp->QueryInterface(LPDIRECTPLAYLOBBY2A, (LPVOID *)&lpdplobby); //error C2275: ''LPDIRECTPLAYLOBBY2'' : illegal use of this type as an expression


You have passed ''LPDIRECTPLAYLOBBY2A'' to QueryInterface. This is not valid, as ''LPDIRECTPLAYLOBBY2A'' is a typename (ie. just like int, or char). You need to pass an object of that type, not the type itself.

Also (and I am not at all sure about this), you are using the same pointer (lpdp) for your DirectPlay interface -and- your DirectPlayLobby interface. I believe you need a different pointer as they are not the same thing. Maybe someone with more experience than I can point out what t do here.
It is perfectly fine to use the LPDIRECTPLAYLOBBY2A

but your problem is you are using the directplay pointer (LPDIRECTPLAY3A) instead of the directplay LOBBY pointer (LPDIRECTPLAYLOBBY2A) to query..

Check out the DirectX section. There is a directplay tutorial I have written before.
I don''t know much about DirectPlay either, but this is a COM problem after all, isn''t it?

How can it be fine to use a type there? How does the compiler pass a type as a parameter of a function? And, to boot, the error message explicitly states that''s he''s "illegally using a type as an expression".

Anyway, the first parameter of the QueryInterface is an "interface ID" (that''s what they''re called isn''t it?). These usually start with "IID_". E.g., in DirectDraw: IID_IDirectDrawSurface, etc.

So he should try:

lpdp->QueryInterface( IID_IDirectPlayLobby2A, (LPVOID *)&lpdplobby);

Well, try that and see how you go, anyway.

-Hotstone

Void:

that code is copied directly from your tutorial. There were a few other errors to....
Hotstone is right..

I must be sleeping while typing that up..

Sorry about that.. I will go back and check for errors and post an updated copy..
Ok.. I have checked and ask gamedev to update the errors.

So far there are two errors reported..

I have checked and there doesn''t seem to be more.. but then my eyes are really tired..zz..

Please inform me if there are more errors.

This topic is closed to new replies.

Advertisement