[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


c++: how to convert wchar_t* to DWORD

Posted on 2006-04-24
Medium Priority
Last Modified: 2008-01-09
I'm reading in a value from an INI file that is the frequency of which I need to perform an action during my file handling process.  The value will always be a postive numeric value.  Default is 32768 (32KB). When I use GetPrivateProfileString() I can read in the value but it comes in as a w_chart*.  I need a way to convert this value to a DWORD.  

Question by:i-mate05
  • 2
LVL 86

Accepted Solution

jkr earned 200 total points
ID: 16528744
Not a big deal, use

#include <stdlib.h>

wchar_t* p = L"32768";
DWORD dwValue = _wtol(p);
LVL 86

Expert Comment

ID: 16528749
BTW, why don't you use 'GetPrivateProfileInt()' here in the 1st place?

Author Comment

ID: 16529351
Thanks for the reply jkr.  Honestly I didn't even realize that call existed. I'm using someone elses code as a guideline and I didn't even think to look for that.  Thank you again.

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
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 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 be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

873 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