Need some assistance configuring registry keys

Posted on 2004-11-08
Last Modified: 2013-11-20
Hi All,

I'm trying to programatically set registry keys to configure a Microsoft Access data source.  One problem I am having is after I set a REG_SZ key's value.  When I look at the key in the registry, the key's value shows up as "my keys value"...

Anyone know why there is a "..." after the key's value?  For some reason, this is not being read by the control panel's data source manager.

Here's my code:
CString dbLocation = "C:\\database.mdb";
CString key = "Software\\ODBC\\ODBC.INI\\MY_DataSource";
HKEY hKey;
DWORD dwType = REG_SZ;

::RegSetValueEx(hKey, "DBQ", 0, REG_SZ, (const unsigned char*)(LPCTSTR)dbLocation, MAX_PATH);

There are other keys but I did not include them as it would be repetitive.

Thanks for your help.
Question by:StanChart
    LVL 86

    Accepted Solution

    >>::RegSetValueEx(hKey, "DBQ", 0, REG_SZ, (const unsigned char*)(LPCTSTR)dbLocation, MAX_PATH);

    Here, you need to specify the *exact* length of the string, thus the '...' part. This should be

    ::RegSetValueEx(hKey, "DBQ", 0, REG_SZ, (const unsigned char*)(LPCTSTR)dbLocation, dbLocation.GetLength());

    Author Comment

    You're the man!

    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

    Suggested Solutions

    Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
    Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    759 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

    8 Experts available now in Live!

    Get 1:1 Help Now