|
skornel wrote: A normal user does not have authority to modify/add existing values in HKLM so if you are specifying KEY_READ | KEY_WRITE as 'samDesired' the RegOpenKeyEx will fail. If you are only going to read leave off the KEY_WRITE, but if you need to modify the value, put it somewhere other than HKLM.
True, but what does all of this have to do with ERROR_ALREADY_EXISTS ?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
It is because, actually you change value in HKCU not in HKLM.
You said, it works for first time and it fails for second time. Well, it works first because there is no key exist before and you have write access. So this is HKCU. It fails second because, you already wrote it when your first time. Probably you do not check result of ImpersonateLoggedOnUser function.
modified on Thursday, May 14, 2009 2:42 AM
|
|
|
|
|
Perhaps you meant to reply to the OP, but after 2 years he may have moved on.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hi, I have an application that I've been running for about 2 years in a production environment and there seems to be a small problem that I think might be the OS, though it doesn't make sense.
The program is running on Windows Server 2003 with SP1. The machine is a dual processor with 2 cores. 4 GB of memory. The program has 9 threads in the pool, and set to use 4 concurrently.
Basically, the program is a distributor of data. One connection sends data, and the program delivers it to other connections if they want it.
There's about 12 connections. 11 of them are local, and 1 is over a DS3.
Anyway, of the 12 connections, the one that is over the DS3 is having the problems. I've done some wireshark sniffs and nothing looks wrong. Plenty of window size, no missing packets, no resends.
The problem is that on that one socket, the WSASend notification sometimes takes 3-4 seconds when it gets really busy. All the other connections that are local don't have the problem. Looking at the sniff, during the 3-4 seconds when no WSASend notification is coming in, I am getting plenty of acknowledgements from the receiving end every 10-20 milliseconds. Also plenty of data is going out. There is no 3-4 second pause in either data being sent or acknowledgements coming in. Nothing close to it even.
So it looks like the OS is queuing up these notifications, but for some reason is only targetting the connection over the DS3, which doesn't make sense...
Any ideas?
|
|
|
|
|
I have been searching the net for a simple database application using visual c++. I want somebody to help me with how to develop just a small application for entering records, deleting, updating and searching using visual c++ and ms sql server 2005. Even if it can be for one record, I can extend that to whatever the number of columns I have in my database. I have been developing some but all in vain. Nothing seems to work.
Please!
phokojoe
|
|
|
|
|
phokojoe wrote: Nothing seems to work
What have you tried that didn't work? Is the problem UI related? Database access related?
phokojoe wrote: how to develop just a small application for entering records, deleting, updating and searching
Maybe break that down into managable chunks and show some sample code that you're having trouble
with and we can hopefully help you out.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
You need to look into using the CDatabase[^] class. Below is come code to read some records from an Access DB which can be easily modified for MS SQL Server. Using those two classes you can update, read, create, etc. I believe I got much of this original code from CP but I cannot for the life of me remember where so I can't credit the author.
CDatabase m_database;
CRecordset *m_recset;
bool Read()
{
CString SqlString;
CString sVideoName, sFileLocationRelative;
CString sDriver = "MICROSOFT ACCESS DRIVER (*.mdb)";
CString sDsn;
CString sFile = "Database\\VideoDB2.mdb";
sDsn.Format("ODBC;DRIVER={%s};DSN='';DBQ=%s",sDriver,sFile);
TRY
{
m_database.Open(NULL,false,false,sDsn);
m_recset = new CRecordset( &m_database );
SqlString = "SELECT * FROM VIDEOS";
m_recset->Open(CRecordset::forwardOnly,SqlString,CRecordset::readOnly);
while( !m_recset->IsEOF() )
{
VideoRecord tVideo;
CDBVariant vID;
CDBVariant vRunTime;
CDBVariant vName;
CDBVariant vImagePath;
CDBVariant vVideoPath;
CDBVariant vDescription;
m_recset->GetFieldValue("VIDEO_ID", vID);
m_recset->GetFieldValue("VIDEO_RUN_TIME", vRunTime);
m_recset->GetFieldValue("VIDEO_NAME", vName);
m_recset->GetFieldValue("VIDEO_IMAGE_PATH",vImagePath);
m_recset->GetFieldValue("VIDEO_PATH", vVideoPath);
m_recset->GetFieldValue("VIDEO_DESCRIPTION",vDescription);
tVideo.iVideoID = vID.m_iVal;
tVideo.lRunTime = vRunTime.m_lVal;
tVideo.stVideoName = *vName.m_pstring;
tVideo.stImagePath = *vImagePath.m_pstring;
tVideo.stVideoPath = *vVideoPath.m_pstring;
tVideo.stDescription = *vDescription.m_pstring;
m_vVideos.push_back(tVideo);
m_recset->MoveNext();
}
m_recset->Close();
}
CATCH(CDBException, e)
{
AfxMessageBox("Database error: "+e->m_strError);
return false;
}
END_CATCH;
return true;
}
By the way, that VideoRecord structure was just a part of my program, so you can ignore it.
Hope this is helpful,
Dustin
|
|
|
|
|
I have an view derived from CScrollView and I make the image fit to width so my horizontal scrollbar disappears. Problem is, I need that scrollbar to remain visible so user can add additional space to the image by clicking the scroll buttons.
I would like to continue to use CScrollView as it still saves a tad bit amount of work and code compared to CView but I'm not having much luck getting the scrollbars to remain visible.
I've tried adding some addtional padding space around the image but it has an undesireable effect and I'm trying to mimic the functionality of some commercial products that do not appear to use padding around the image.
Does anyone know how to force the scrollbars in CScrollView to remain visible and enabled?
|
|
|
|
|
bob16972 wrote: Does anyone know how to force the scrollbars in CScrollView to remain visible and enabled?
Try calling SetScrollSizes() in OnInitialUpdate() after the call to the base class. Add the amount of additional space you need.
|
|
|
|
|
Unfortunately, I do that already dynamically as the view size changes (use SetScrollSizes() that is) and I tried adding some padding to force the scroll bars to remain visilbe but the effect would be somewhat confusing to the user as it is a fit to width application.
Some commercial products allow the user to temporarily scroll beyond the image edge and add some drawing primitive or object and recalculate the page size and readjust the scroll sizes on the next view resize or scroll bar action to remove the excess space that wasn't needed. They leave the horizontal scroll bar visible but the thumb is full size (or darn near close to it). VC++ 6.0 kinda does this when you scroll past the bottom of a document.
Thanks for taking the time to give me some advice. When it appears that I might be creating more work than necessary, I like to get some professional feedback as a sanity check. Unfortunatley, it looks like I'm going to have to derive from CView at this point.
Thanks again and take care.
|
|
|
|
|
I'm not sure how much you're going to have to fight the MFC code to do this.
Take a look at the source (viewscrl.cpp), particularly all the calls to SetScrollInfo() and
SetScrollRange().
There's the SIF_DISABLENOSCROLL flag for SetScrollInfo() but while letting the bar remain shown,
it will be disabled which isn't what you need.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I'm betting I'm going to have to revert back to deriving from CView.
I guess I'll earn my pay today.
Thanks for taking the time to share your thoughts and advice.
|
|
|
|
|
Why the wizard dont give a destructor for the CDialog derived class.
Is there a special reason?
Thnak you.
KIRAN PINJARLA
|
|
|
|
|
kiran.pinjarla wrote: Why the wizard dont give a destructor for the CDialog derived class.
Its not always necessary. But if you need it, just add it.
|
|
|
|
|
Thak you.
I just wanted that.
KIRAN PINJARLA
|
|
|
|
|
Hi,
As all the destructors. The reason is to free the possible resources that have to be removed to avoid memory leaks or trash in memory. Specially the ones you are using during the whole life-time of the Dialog itself.
The only problem with that is that you can not free "graphical" resources because you don't have the parent window (the dialog) anymore, so the m_hWnd is NULL and is impossible to access them. In this point is better to use the WM_CLOSE because it is called just before destroying the window/dialog.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
how to get a ascii value of address in ip address control
|
|
|
|
|
prathuraj wrote: how to get a ascii value of address in ip address control
Do you mean the textual representation of the IP address?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
i want to get ascii value because i cant differenciate (. . . .) and (0.0.0.0) in ipaddress control.I want to check each field in ipaddress control with space or zero.how to do that
I read the value from ipaddress control by Getdlgitem(id)->getWindowtext(cstring)
|
|
|
|
|
Have you ignored the GetAddress() method? In addition to getting the actual value from the control, it returns the number of non-blank fields.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
how to use getaddress function for dynamic one
|
|
|
|
|
prathuraj wrote: ...for dynamic one
You created a "SysIPAddress32" control dynamically?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
no,I used the class CIPAddressCtrl
|
|
|
|
|
prathuraj wrote: I used the class CIPAddressCtrl
Which has no bearing on whether you created the underlying control at design time or at run time (i.e., dynamic).
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I've written a little web crawler in VC++, which grabs financial indices and quotes from different websites and shows them.
If the sources are plain html, everything is fine.
Now I've got a website which shows the quotes dynamically (http://www.forexpf.ru/quote_show.php[^]).
IMHO there are 2 ways to get the information extracted:
1. grab the page as image, make OCR and extract the info
2. load the page into a browser control to build the content, copy the content text (into clipboard) and extract information
#1 works in general, but ocr actually isn't accurate enough.
#2: Are there any examples to show the handling of clipboard?
On the other hand: Use of clipboard wouldn't be my first choice because the grab process is repeated automatically in background and with use of clipboard other applications running would be influenced. Are there any other ideas to solve the problem?
TIA
M.
|
|
|
|