Solved

How do i convert char * to DWORD_PTR or DWORD

Posted on 2006-11-01
5
1,405 Views
Last Modified: 2008-01-09
hi,

How do i convert char * to DWORD_PTR or DWORD
0
Comment
Question by:jyotishb
  • 2
5 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 17855994
Like

char* pc = "42";

DWORD* pdw = (DWORD*) pc;
DWORD dw = (DWORD) pc;

However, without knowing what you are exactly trying to accomplish, use that with caution.
0
 

Author Comment

by:jyotishb
ID: 17856008
well,
i m trying to use this method

void CALLBACK waveInProc(
  HWAVEIN hwi,      
  UINT uMsg,        
  DWORD_PTR dwInstance,  
  DWORD_PTR dwParam1,    
  DWORD_PTR dwParam2    
);



and i need to pass a char * to the instance varialve dwInstance

what would be the best way to do it..



0
 
LVL 86

Accepted Solution

by:
jkr earned 250 total points
ID: 17856034
The way as outlined above. Since that has to be speified whe calling 'waveInOpen()', use it like

waveInOpen( phwi,uDeviceID,&wfx,dwCallback,(DWORD) "test,fdwOpen);

and get it back in the callback as

void CALLBACK my_waveInProc(
  HWAVEIN hwi,      
  UINT uMsg,        
  DWORD_PTR dwInstance,  
  DWORD_PTR dwParam1,    
  DWORD_PTR dwParam2    
)
{
  char* psz = (char*) dwInstance;
}

0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now