|
Look at the last parameter passed to RegQueryValueEx().
This variable needs to be initialized to the size of the return buffer, in BYTES (NOT characters).
On return, this variable will be set to the number of bytes copied to the buffer, including null terminators.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
What's wrong with you... stop reading the documentation! That's not what it's for.
|
|
|
|
|
LOL
Do people really just plug values into APIs until it compiles and then keep
changing the values until it runs? How do they find the APIs to begin with?
That's gotta be a frustrating way to write software.
To each his own, I guess
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: That's gotta be a frustrating way to write software a virus.
|
|
|
|
|
Mark Salsbery wrote: Do people really just plug values into APIs until it compiles and then keep
changing the values until it runs? How do they find the APIs to begin with?
Stop giving away my secrets, Mark. Good grief. Is nothing sacred anymore?
"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
|
|
|
|
|
|
pther wrote: Pls tell me what is wrong with it.
You are in a much better position to do this than us. What is the code (not) doing?
pther wrote: if( lReturnCode!= ERROR_SUCCESS)
::RegCloseKey(hKey);// Close key
else
::RegCloseKey(hKey);
Shouldn't you be calling RegCloseKey() regardless of what RegQueryValueEx() returns?
pther wrote: The string I am getting is NULL.
What string? Using the debugger, have you stepped through the code?
"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
|
|
|
|
|
question one:
CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
m_splitterWnd.CreateStatic(this,1,2);
m_splitterWnd.CreateView(0,0,RUNTIME_CLASS(CViewLeft),CSize (100,300),pContext);
m_splitterWnd.CreateView(0,1,RUNTIME_CLASS(CEditViewRight),CSize(100,100),pContext);
return TRUE;
}
the CViewLeft derived from CView, the CEditViewRight derived from CEditView, both them have OnDraw() function, but after debugging, only go into CViewLeft OnDraw(), not go into CEditViewRight OnDraw() , what's the matter?
question two:
I want to creat 2 rows 2 col views as following:
CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
m_splitterWnd.CreateStatic(this,2,2);
m_splitterWnd.CreateView(0,0,RUNTIME_CLASS(CFormViewUpLeft),CSize (100,300),pContext);
m_splitterWnd.CreateView(0,1,RUNTIME_CLASS(CFormViewUpRight),CSize(100,100),pContext);
m_splitterWnd.CreateView(1,0,RUNTIME_CLASS(CFormViewLowLeft),CSize (100,300),pContext);
m_splitterWnd.CreateView(1,1,RUNTIME_CLASS(CFormViewLowRight),CSize(100,100),pContext);
return TRUE;
}
but it is no function, any suggestion? thanks
|
|
|
|
|
Question one...
The edit view never has to draw anything, as its all covered up by an edit control - and *that* does it's own drawing.
Question two...
No idea. You'd best step into the CreateView functions and see why. I'd guess that one of the form view's dialogs aren't creating properly.
Try it with a very boring form view, with only a "hello world" static control, and build up from there.
Iain.
|
|
|
|
|
thanks Iain.
i will try as your suggestion.
|
|
|
|
|
hi can any body tell me how to add libraries in C++ using visual studio 2005
i downloaded JXTA-C and this requires APR ,OpenSSL ,zlib ,sqlite3 ,xml2 and expat but im not sure how to add them in Visual studio
|
|
|
|
|
On the Project-Explorer you choose the menu-item "Add an existing Element"
then you choose the .lib files.
It works also over the project properties, there is a special entry for extern libs.
Good luck 
|
|
|
|
|
Anyone have any idea if Java is faster than C++ at run time?
This code was executed and it took java 2.5 secs to complete whereas it took c++ 11 secs.
Any input is appreciated.
thanks,
long start_time = System.currentTimeMillis();
System.out.println("Starting... ");
for (int i = 0; i < 1000000000; i++)
{
int j = 5;
j++;
j *= 2;
j /= 2;
j--;
double k = 5.0;
k++;
k *= 2;
k /= 2;
k--;
}
System.out.println("Ending. Time taken: " +
(System.currentTimeMillis() - start_time) + " milisec");
|
|
|
|
|
LCI wrote: This code was executed and it took java 2.5 secs to complete whereas it took c++ 11 secs.
There are way too many variables involved in order for this to be an accurate assessment. You are, in effect, comparing apples to oranges.
"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
|
|
|
|
|
Not sure i understand why this is not an fair assessment. Can you elaborate when you say that i am comparing apples to oranges?
|
|
|
|
|
LCI wrote: Can you elaborate when you say that i am comparing apples to oranges?
Why do people insist on comparing C++ and Java? Consider reading The Design and Evolution of C++ (D&E) to see why C++ is the way it is, and consider both languages in the light of their design criteria. Those criteria will obviously differ from the criteria of Sun's Java team. Despite the syntactic similarities, C++ and Java are very different languages. In many ways, Java seems closer to Smalltalk than to C++.
"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
|
|
|
|
|
For one, how can you verify that the loops were fully processed without some output of the value in the end?
You need to modify a value on each iteration, and use the final value in some output in both systems to prevent optimizations in Java from throwing the whole loop away and not even processing it. You may be the victim of a false positive since it may not have processed things as you think in both environments. You need to understand what happens in optimized and debug modes to properly set up your benchmarks and to fully appreciate and digest the results of your tests.
You can inadvertantly benchmark using debug mode so make sure, if you haven't already, to only benchmark in releasemode.
|
|
|
|
|
please, try this:
int j;
double k;
for (int i = 0; i < 1000000000; i++)
{
int j = 5;
j++;
j *= 2;
j /= 2;
j--;
double k = 5.0;
k++;
k *= 2;
k /= 2;
k--;
}
how many seconds?
Russell
|
|
|
|
|
0, if you build an optimized version of the C++ code (see my full answer below, but basically the C++ compiler works out that the body of the loop is a no-op and throws the whole loop away!)
|
|
|
|
|
I was only trying to do the easyest optimization to beat 2.5 sec.
;P
Russell
|
|
|
|
|
Do you know if Java has the concept of Debug vs. release builds?
|
|
|
|
|
I don't think the Java-to-bytecode compiler has different options here. I'm more familiar with C#, where the C#-to-IL compiler csc does have a /debug option. This has the effect of inserting a certain number of nop IL instructions to ensure that line number information lines up and that you can put a breakpoint on some lines that otherwise wouldn't be possible (for example on the closing brace of a block). Further, it emits a DebuggableAttribute which the JIT compiler detects - this disables JIT optimizations to make the code easier to debug. I don't know if Java JIT compilers have similar options.
Compiling a similar C# program with C# 2.0 gives 10.8s on my home computer with /debug:full and 1.078 second with /debug:pdbonly . With /debug- it's 1.062s. I should say here that my home computer ran the unoptimized C++ version in 14.4s - it's a Core 2 Duo T7200-based laptop (2.0GHz) whereas my work computer is a P4 3.0GHz with HyperThreading enabled. It looks, from sticking a call to System.Diagnostics.Debugger.Break at the top of Main and looking at the disassembly in VS, like it's managed to eliminate the contents of the loop but not the loop itself; however, it's keeping and manipulating the loop counter variable in a register.
|
|
|
|
|
In fact, the optimizer should have taken care of this. It should, in fact, have made the int into a register.
What went wrong?
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
yes, but optimization is something that is not everytime clear/sure for the user...look at your words:
jhwurmbach wrote: he optimizer should have taken care of this
the only way to know what appens after compile is to look to the assembler code...or, better, don't think to compare the same code written in different languages without considering optimizations, code-shortcuts, assembler translation, ...
Optimization is a too wide chapter to think to understand everithing with only a sample code
Russell
|
|
|
|
|
Russell` wrote: optimization is something that is not everytime clear/sure for the user
Sure.
Mike Dimmik did his study while I was writing my reply.
I got 19,3 and 3,4*10^-7 seconds in debug and relase, respectivly.
I took this as "quite a lot" and "practically nothing" and asked where the 2,5 seconds came from. I doubt that there is a computer 10 times as fast as my double Xeon 2.4 Ghz...
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|