Solved

How do i convert char * to DWORD_PTR or DWORD

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

How do i convert char * to DWORD_PTR or DWORD
0
Comment
Question by:jyotishb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

728 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