473,847 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

A question of pointers..

Hei!

I explored DirectX 8.1 SDK and found TUT09_ClientSer ver it includes the
following code as a part of the tutorial...

//----

HRESULT WINAPI DirectPlayMessa geHandler(PVOID pvUserContext, DWORD
dwMessageId, PVOID pMsgBuffer)
{
HRESULT hr = S_OK;

switch (dwMessageId)
{
case DPN_MSGID_RECEI VE:
{
PDPNMSG_RECEIVE pMsg;

pMsg = (PDPNMSG_RECEIV E) pMsgBuffer;

printf("\nRecei ved Message: %S\n", (WCHAR*)pMsg->pReceiveData );
break;
}
}
return hr;
}

//----

And, now the actual question : How do i change the pMsg->pReceiveData to
point to my pointer " int *g_myData " and load the data to my pointer..

Well, thats about it, not that bad..

Thank you greatly for your helping tips.

Yours : JariTapio / Helsinki / 06 July 2005
Jul 23 '05 #1
4 1513
And, now the actual question : How do i change the pMsg->pReceiveData to
point to my pointer " int *g_myData " and load the data to my pointer..


Do you mean:
int *g_myData
// fill g_myData here.
PDPNMSG_RECEIVE pMsg;
PMsg = static_cast<PDP NMSG_RECEIVE>(g _myData);

or do you mean
PDPNMSG_RECEIVE pMsg;
pMsg = static_cast<PDP NMSG_RECEIVE>(p MsgBuffer);
int* g_myData = static_cast<int *>(pMsg);
Which can be shortened to:
int* g_myData = static_cast<int *>(pMsgBuffer) ;

Jul 23 '05 #2
Hei!

hmm.. im still not talantet enough.. Dam hell..
well lets try again..
I have two functions (both workin fine) one for sending strings and one for
receivin ones ( DX8.1SDK TUT09_ClientSer ver )..

If we watch the CLIENT code we can find my question i received some help
from mr Velthuijsen but i did not get my code running properly...
SERVER CODE FOLLOWS::
//-----------------------------------------------------------------------------
// Name: SendDirectPlayM essage()
// Desc: Sends a DirectPlay message to all players
//-----------------------------------------------------------------------------
HRESULT SendDirectPlayM essage()
{
HRESULT hr = S_OK;
DPN_BUFFER_DESC dpnBuffer;
WCHAR wszData[256];

// Get the data from the user
printf("\nPleas e Enter a String.\n");
wscanf(L"%ls", wszData);
dpnBuffer.pBuff erData = (BYTE*) wszData;
dpnBuffer.dwBuf ferSize = 2 * (wcslen(wszData ) + 1);

if( FAILED( hr = g_pDPServer->SendTo(DPNID_A LL_PLAYERS_GROU P, // dpnid
&dpnBuffer, //
pBufferDesc
1, //
cBufferDesc
0, //
dwTimeOut
NULL, //
pvAsyncContext
NULL, //
pvAsyncHandle
DPNSEND_SYNC | //
dwFlags
DPNSEND_NOLOOPB ACK ) ) )
{
printf("Failed Sending Data: 0x%x\n", hr);
}
return hr;
}

CLIENT CODE FOLLOWS::
//-----------------------------------------------------------------------------
// Name: DirectPlayMessa geHandler
// Desc: Handler for DirectPlay messages.
//-----------------------------------------------------------------------------
HRESULT WINAPI DirectPlayMessa geHandler(PVOID pvUserContext, DWORD
dwMessageId, PVOID pMsgBuffer)
{
HRESULT hr = S_OK;

switch (dwMessageId)
{
case DPN_MSGID_RECEI VE:
{
PDPNMSG_RECEIVE pMsg;

pMsg = (PDPNMSG_RECEIV E) pMsgBuffer;

printf("\nRecei ved Message: %S\n", (WCHAR*)pMsg->pReceiveData );

// HOW DO I CHANGE THE LINE, TOP OF THIS QUESTION, TO FORM TO
RECEIVE DATA TO "char/word/int g_MyData[256]"
// I TRYED THE CODE *g_MyData = (char *) pMsg->pReceiveData ; BUT IT
GIVES ME AN ERROR.

break;
}
}
return hr;
}
Thank you greatly for your helping tips.

Yours : JariTapio / Helsinki / 06 July 2005
Jul 23 '05 #3
I get my code working thank you...
Jul 23 '05 #4
JariTapio wrote:
I get my code working thank you...


One thanks the newsgroup by answering questions (and questioning answers)
here.

--
Phlip
http://www.c2.com/cgi/wiki?ZeekLand
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

27
3418
by: Susan Baker | last post by:
Hi, I'm just reading about smart pointers.. I have some existing C code that I would like to provide wrapper classes for. Specifically, I would like to provide wrappers for two stucts defined as ff: typedef struct { float *data ; int count ;
3
3460
by: ozbear | last post by:
This is probably an obvious question. I know that pointer comparisons are only defined if the two pointers point somewhere "into" the storage allocated to the same object, or if they are NULL, or one-past the end of the object as long as it isn't dereferenced. I use "object" in the standard 'C' sense. Is there some special dispensation given to comparing two pointers
9
5071
by: Mikhail Teterin | last post by:
Hello! I'd like to have a variable of a pointer-to-function type. The two possible values are of type (*)(FILE *) and (*)(void *). For example: getter = straight ? fgetc : gzgetc; nextchar = getter(file); What type should I give to `getter' so that the compiler does not issue
12
4100
by: Lance | last post by:
VB.NET (v2003) does not support pointers, right? Assuming that this is true, are there any plans to support pointers in the future? Forgive my ignorance, but if C# supports pointers and C# and VB.NET get compiled into the same code, then I don't understand why VB.NET can't support pointers Thanks for any info Lance
14
2849
by: Alf P. Steinbach | last post by:
Not yet perfect, but: http://home.no.net/dubjai/win32cpptut/special/pointers/ch_01.pdf http://home.no.net/dubjai/win32cpptut/special/pointers/ch_01_examples.zip To access the table of contents, use the "Bookmarks" tab in Adobe Acrobat. Comments, corrections, praise, nits, etc., are still welcome!
92
5152
by: Jim Langston | last post by:
Someone made the statement in a newsgroup that most C++ programmers use smart pointers. His actual phrase was "most of us" but I really don't think that most C++ programmers use smart pointers, but I just don't know. I don't like them because I don't trust them. I use new and delete on pure pointers instead. Do you use smart pointers?
4
3520
by: Josefo | last post by:
Hello, is someone so kind to tell me why I am getting the following errors ? vector_static_function.c:20: error: expected constructor, destructor, or type conversion before '.' token vector_static_function.c:21: error: expected constructor, destructor, or type conversion before '.' token
25
13074
by: J Caesar | last post by:
In C you can compare two pointers, p<q, as long as they come from the same array or the same malloc()ated block. Otherwise you can't. What I'd like to do is write a function int comparable(void *p, void *q) that will take any two pointers and decide whether they can be compared or not. I really can't think how to do this - any suggestions?
54
12042
by: Boris | last post by:
I had a 3 hours meeting today with some fellow programmers that are partly not convinced about using smart pointers in C++. Their main concern is a possible performance impact. I've been explaining the advantages of smart pointers endlessly (which are currently used in all our C++ software; we use the Boost smart pointers) as I'm seriously concerned that there is a shift to raw pointers. We are not developing system software but rather...
2
2990
by: StevenChiasson | last post by:
For the record, not a student, just someone attempting to learn C++. Anyway, the problem I'm having right now is the member function detAddress, of object controller. This is more or less, your standard dynamic address book program. Adding, and listing work just fine. However, deleting, editing and viewing relies on member function retAddress. This function returns an array of pointers that are pointing to created objects. In action, all it...
0
9730
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10983
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10648
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10707
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10341
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9485
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7883
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5911
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4529
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.