 |
 |
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode HTML tags when pasting" checkbox before pasting anything inside the PRE block, and make sure "Ignore HTML tags in this message" check box is unchecked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question in one forum from another, unrelated forum (such as the lounge). It will be deleted.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
I'm using Visual Studio 2013.
I don't konw why get crash in these following scenarios. What am I missing?
Crash in this function:
extern "C" _CRTIMP int __cdecl _CrtIsValidHeapPointer(
const void * pUserData
)
{
if (!pUserData)
return FALSE;
if (!_CrtIsValidPointer(pHdr(pUserData), sizeof(_CrtMemBlockHeader), FALSE))
return FALSE;
return HeapValidate( _crtheap, 0, pHdr(pUserData) );
}
Scenario 1:
std::shared_ptr<int> foo()
{
std::shared_ptr<int> p(new int(10));
size_t cnt = 10;
while (cnt--)
p.get()[cnt] = roll_die();
return p;
}
void func(int* ptr, size_t cnt)
{
while (cnt--)
{
cout << ptr[cnt] << endl;
}
}
void main()
{
std::shared_ptr<int> u_ptr = nullptr;
u_ptr = foo();
func(u_ptr.get(), 10);
}
Scenario 2:
std::unique_ptr<int> foo()
{
std::unique_ptr<int> p(new int(10));
size_t cnt = 10;
while (cnt--)
p.get()[cnt] = roll_die();
return p;
}
void func(int* ptr, size_t cnt)
{
while (cnt--)
{
cout << ptr[cnt] << endl;
}
}
void main()
{
std::unique_ptr<int> u_ptr = nullptr;
u_ptr = foo();
func(u_ptr.get(), 10);
}
modified 7 hrs ago.
|
|
|
|
|
 |
CPallini wrote: Scenario 1 doesn't 'crash' on my system.
I'm using Visual Studio 2013.
|
|
|
|
 |
Please, see my updated answer.
Veni, vidi, vici.
|
|
|
|
 |
It took a while, but I just figured that out too. :(
|
|
|
|
 |
Richard MacCutchan wrote: t took a while, but I just figured that out too.
Yes, sometimes it takes a while to figure out we need more and more caffeine.
Veni, vidi, vici.
|
|
|
|
 |
CPallini wrote: we need more and more caffeine. Speak for yourself, I need more brain.
|
|
|
|
 |
Me too. Caffeine is way more practical, though.
Veni, vidi, vici.
|
|
|
|
 |
Hi,
The std::unique_ptr[^] is unique meaning non-assignable and non-copyable so you will need to use move semantics to pass it around or give up ownership with unique_ptr::release()[^].
func(u_ptr.release(), 10);
Best Wishes,
-David Delaune
|
|
|
|
 |
In ms paint save as option is there i want the sample code for that .can any body give ..or anybody have share it. please its urgent because what iam doing means i have images which are not fixed to screen so many images are there iam scrolling and taking screen shots and thats why its flickering.i saw ms paint save as image in png format how much u will have image it will not flicker. please help give code for ms paint save image code in mfc
modified yesterday.
|
|
|
|
 |
Please detail a little bit .. .you want to save something that you paint ? As bitmap ?
|
|
|
|
 |
imran.prdc wrote: i want the sample code
imran.prdc wrote: please help give code
In both cases, if you want sample code then you should go and search for it, There are many articles that can be found here on CodeProject, or by Google, that show how to manage images.
|
|
|
|
 |
please give me some links
|
|
|
|
 |
please give me some links which are useful
|
|
|
|
 |
I already told you where to look, please make an effort to do your own research.
|
|
|
|
 |
No. We can't. You haven't described your problem well enough for us to properly search for it. Only you know what you need exactly, so you do the search!
Besides, even if you took the time to precisely describe what you want, it would take as at least as much time to search for those links as it would take you - so why should we? Please learn to use the search function, here, on google, or on any other site that you might consider useful (e. g. MSDN). That will save everyone a lot of time - including yourself!
|
|
|
|
 |
Hi all,
While debugging the following code,
inline LONG CRegKey::QueryValue(LPTSTR szValue, LPCTSTR lpszValueName, DWORD* pdwCount)
{
ATLASSERT(pdwCount != NULL);
DWORD dwType = NULL;
LONG lRes = RegQueryValueEx(m_hKey, (LPTSTR)lpszValueName, NULL, &dwType,
(LPBYTE)szValue, pdwCount);
ATLASSERT((lRes!=ERROR_SUCCESS) || (dwType == REG_SZ) ||
(dwType == REG_MULTI_SZ) || (dwType == REG_EXPAND_SZ));
return lRes;
}
Here the value for (LPTSTR)lpszValueName is 'SQLPath' and the value which returns for 'szValue' in RegQueryValueEx method is “c:\Program Files (x86)\Microsoft SQL Server\100\Tools\” which should be “c:\Program Files\Microsoft SQL Server\100\Tools\”
We have noted that the data value for SQLPath in RegistryKey "SOFTWARE\Microsoft\Microsoft SQL Server\100\Tools\ClientSetup" is “c:\Program Files\Microsoft SQL Server\100\Tools\”
Could anybody please tell why RegQueryValueEx method is returning a wrong value “c:\Program Files (x86)\Microsoft SQL Server\100\Tools\” which should be “c:\Program Files\Microsoft SQL Server\100\Tools\”
Thanks in advance
|
|
|
|
 |
It may be that you are running a 32 bit application, in which case it will use Program Files (x86) , which is where the 32-bit versions are located.
|
|
|
|
 |
Thanks a lot!!
|
|
|
|
 |
When a 32 bit application accesses the path starting with SOFTWARE under the key HKEY_LOCAL_MACHINE on a 64 bit OS, there is a Wow6432Node added automatically after the SOFTWARE. So the path you really accessed was
"SOFTWARE\Wow6432Node\Microsoft\Microsoft SQL Server\100\Tools\ClientSetup"
instead of the one you expected.
Depening on what you want to use the information for, you may need to compile your app as x64.
The good thing about pessimism is, that you are always either right or pleasently surprised.
|
|
|
|
 |
Thanks a lot!!
|
|
|
|
|
 |
Thanks a lot David!!
|
|
|
|
 |
|