Article View: borland.public.cppbuilder.nativeapi
Article #1882Re: problems of saving a registry key to a file
From: Remy Lebeau (TeamB)
Date: Tue, 29 May 2007 19:59
Date: Tue, 29 May 2007 19:59
39 lines
2098 bytes
2098 bytes
"han" <hanzhangusa@yahoo.com> wrote in message
news:465c84a0$1@newsgroups.borland.com...
> I tried using GetLastError(), it says the "the Operation completed
> successfully". It is so strange.
That means that GetLastError() is being cleared before SaveKey()
exits, probably by RegCloseKey(). So you will have to do what dhoke
suggested in the .ide newsgroup - use the Win32 API directly instead
of TRegistry. For example:
HKEY hKey;
LONG lResult;
DWORD dwErr;
lResult = RegOpenKeyEx(HKEY_CURRENT_USER,
"Software\\XXXCompany\\Settings\\ViewForms", 0, KEY_ALL_ACCESS,
&hKey);
if( lResult == ERROR_SUCCESS )
{
lResult = RegSaveKey(hKey, "tempReg", NULL);
if( lResult != ERROR_SUCCESS )
{
dwErr = GetLastError();
Application->MessageBox(("save key error: " +
AnsiString(dwErr)).c_str(), NULL, MB_OK);
}
RegCloseKey(hKey);
}
else
{
dwErr = GetLastError();
Application->MessageBox(("open key error: " +
AnsiString(dwErr)).c_str(), NULL, MB_OK);
}
Gambit
Technical Details
Message-ID:
<465c8700$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<465a6397@newsgroups.borland.com> <465b4af1$1@newsgroups.borland.com> <465b9222$2@newsgroups.borland.com> <465bf3c5$1@newsgroups.borland.com> <465c84a0$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,321743db05a8d51 X-Google-Attributes: gid10cc67,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <465a6397@newsgroups.borland.com> <465b4af1$1@newsgroups.borland.com> <465b9222$2@newsgroups.borland.com> <465bf3c5$1@newsgroups.borland.com> <465c84a0$1@newsgroups.borland.com> Subject: Re: problems of saving a registry key to a file Date: Tue, 29 May 2007 12:59:40 -0700 Lines: 41 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 75.82.252.126 Message-ID: <465c8700$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1180468992 75.82.252.126 (29 May 2007 13:03:12 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail