c++: how to convert wchar_t* to DWORD

Posted on 2006-04-24
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
    LVL 86

    Accepted Solution

    Not a big deal, use

    #include <stdlib.h>

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

    Expert Comment

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

    Author Comment

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
    Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
    The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
    The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

    779 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

    13 Experts available now in Live!

    Get 1:1 Help Now