Click here to Skip to main content

Comments by Ajay Vijayvargiya (Top 45 by date)

Ajay Vijayvargiya - 4 Jan '12 - 1:20 View
Becauase the OP doesn't know only 'new' will call the constructor, and 'malloc' won't call it. And therefore `std::map` doesnt get initialized, and hence the crash.
Ajay Vijayvargiya - 5 May '11 - 22:57 View
Well, that simply means the EXE should have .LIB file with it, OR the DLL would load the function dynamically using GetProcAddress. I would prefer a callback function, which would be imported from DLL, and EXE would call that function, passing the address (name) of the function in EXE.
Ajay Vijayvargiya - 2 May '11 - 10:13 View
I agree with you Stefan. But when asked "platform dependent language", obvious answer would be C/C++, and when asked "PI language", Java would come out. A Java compiler produces byte-code, and therefore it can be executed on compliant JVM without any changes - the same binary can be shipped to multiple platforms. But that's not possible with C++ - it is native binary. And that's the reason languages are categorized.
Ajay Vijayvargiya - 2 May '11 - 8:17 View
Please control your emotions and specially you Language. I am not a Java guy, but a hardcore C++ guy. Do check the profile of before making such kind of abusive statement.
Ajay Vijayvargiya - 2 May '11 - 3:39 View
My statement implied that Java is PI, not C++! C++ is DEPENDENT on platform. A binary generated using X compiler on Y platform, may not run on Z platform.
Ajay Vijayvargiya - 2 May '11 - 3:36 View
Looks like basic pointer level misunderstanding! :) Edit: Not to answer, but to Brain!
Ajay Vijayvargiya - 2 May '11 - 0:27 View
Platform Independent? Then what is Java?
Ajay Vijayvargiya - 2 May '11 - 0:14 View
HOW are you calling the function? What exact parameters?
Ajay Vijayvargiya - 2 May '11 - 0:13 View
Start command prompt (cmd.exe), and run from there. See any error you might see on console. And I am confused: You need access or you dont need full-access (i.e. you require Admin, or Non-Admin) ?
Ajay Vijayvargiya - 30 Apr '11 - 3:09 View
Same thing I said buddy, all numbers are stored in binary. So, you cannot say int is stored as base-2, and double is stored as base-10. Both are stored as sequence of bits (and therefore we have datattype-sizes). May be my statement was somewhat elusive...
Ajay Vijayvargiya - 30 Apr '11 - 2:48 View
It has nothing do with base of number. Integer numbers are stored as actual values, real numbers are stored as formula (mantissa, exponent). See IEEE for the explanation. Therefore, when you retrieve the float/double number, it is CALCULATED, and therefore may be bit imprecise.
Ajay Vijayvargiya - 2 Feb '11 - 21:57 View
Now what Polymorphism has to do with this?
Ajay Vijayvargiya - 2 Feb '11 - 1:17 View
Dare to mention the uselessness?
Ajay Vijayvargiya - 24 Jan '11 - 22:15 View
I don't use gotos either. My point was "how to avoid goto, if used"
Ajay Vijayvargiya - 17 Jan '11 - 9:09 View
Direct answer: No. No exception happens on unbalanced ECS, LCS. A buffer overrun can cause practically anything, and a CS corruption can easily be one of them.
Ajay Vijayvargiya - 17 Jan '11 - 1:34 View
"Also, please do me a favour: in case you figure out what's going on, share your experience." What else do I need to mention? I cannot share the full source code, nor anything about the "product".
Ajay Vijayvargiya - 17 Jan '11 - 1:31 View
Windows Server 2008 R2, x64. Yes, the code is artificial reproduction of the exception. It may not occur on other platforms; as I have seen in WS2003 it doesn't occur. See, I am not very much concerned about exact reason of exception, but I wanted if there is possibility to have exception when CS object is directly modified. In my original case, An application has crashed, and crash dump analysis as well as application event shows 0xC0000264. I coded above code to make sure it is not because of unbalanced Enter/Leave, but because of CS corruption - and that's it! :)
Ajay Vijayvargiya - 16 Jan '11 - 9:33 View
I saw that article, and this exception (as author mentions) may occur when SRW functions.
Ajay Vijayvargiya - 16 Jan '11 - 9:31 View
Let me make it more simple. A CRITICAL_SECTION object is under a struct/class, and that structure is being accessed from somewhere and there is possibility that some buffer overflow may corrupt one of more variables of CRITICAL_SECTION object. A mis-balanced Enter/Leave will not cause this exception.
Ajay Vijayvargiya - 15 Jan '11 - 11:32 View
Please don't edit title: "NEED" is correct
Ajay Vijayvargiya - 15 Jan '11 - 11:31 View
Just edited! :) BTW, I did not say about "waiting" but about timeout specification while waiting (which I did not know!)
Ajay Vijayvargiya - 15 Jan '11 - 11:20 View
Timeout with critical-section?? EDIT: I read about timeout registry settings, and yes it is possible to set timeout. I did not know this. Thanks! But again, this is not relevant to problem in hand. There is critical section in some structure, and that structure is probably being modified, causing the internal state of CRITICAL_SECTION to get modified. And this results in said exception when LeaveCriticalSection is called.
Ajay Vijayvargiya - 15 Jan '11 - 11:18 View
I am afraid to say that this doesn't add anything to the problem in hand. All I wanted to raise exception on LeaveCriticalSection. If you see my profile, you can find I know all about multithreading stuff.
Ajay Vijayvargiya - 29 Oct '10 - 14:02 View
It doesn't shows up, or it doesn't allow you to type ?
Ajay Vijayvargiya - 28 Oct '10 - 11:35 View
GetModuleFileName, to get current directory? I think you mean GetCurrentDirectory.
Ajay Vijayvargiya - 28 Oct '10 - 4:41 View
Depends. Even I haven't used this trick. Just shared it. And if you say is it bad design, what about 'partial' keyword on C# ?
Ajay Vijayvargiya - 23 Oct '10 - 15:05 View
And seriously, from my perspertive, streaming, buffering and flushing is bad bad design for a message box. Come on man, you don't collect data for a messsage box from multiple sources, wait for new messages/events to come, and then "flush" the message box.
Ajay Vijayvargiya - 23 Oct '10 - 14:59 View
I just read the added stuff. My point was *just* to avoid formatting calls, if any, and use the MessageBoxFormatted directly, and nothing else. In MFC, CString is there, the + operators are there, even the stringstream (don't know exact classname) is there where << operator may be used for any datatype (where CString wouldn't work). Why do you need this extra stuff just for a messagebox?? For readers, this is truly an alternate, but not for me! :)
Ajay Vijayvargiya - 21 Oct '10 - 8:56 View
Quite good, and powerful. But not adaptable easily. My point was to omit the variable declaration, formatting (either wise), and then call function to display message box. Your solution requires variable declaration. And I don't see how << can be used in cascaded manner. Would it display multiple message box or one? Now, Again, you need to add one more line! I regularly use templates and advancements in compiler and tools. But I found this extraneous!
Ajay Vijayvargiya - 19 Oct '10 - 7:05 View
Class is good, no issues regardning that. But it is not flexible enough to "inline" where you just need to create a thread. Since this is just a tip/trick, I did not expand it - I have more ideas about this, that would allow to create threads even within classes, as sumple as calling a function.
Ajay Vijayvargiya - 19 Oct '10 - 5:51 View
And how do you use it? I assume it is more complex than CreateThread, AfxBeginThread.
Ajay Vijayvargiya - 18 Oct '10 - 23:00 View
Even I dont agree. But this point it re-usability, and I think you missed that point.Instead of writing a code that meets the function prototype (arguments, return type, calling convention) of the thread-creation function, you can carefully write a thread delegator once, and then just use that delegator on most basic function. Don't compare it with one thread in a system, but dozen threads (with different thread-procs) in a system. Even by reading all this, you may not agree, but you will understand it sooner or later! :)
Ajay Vijayvargiya - 14 Oct '10 - 14:26 View
Cannot accept it as Alternate Solution, it just your feedback!
Ajay Vijayvargiya - 14 Oct '10 - 14:25 View
Absolutely. I had finalized with that thing. But I see this Tip/Trick became long, so I froze!
Ajay Vijayvargiya - 14 Oct '10 - 2:30 View
My mistake. Did not read it properly. Yes, you said it right, we cannot determine this way!
Ajay Vijayvargiya - 14 Oct '10 - 2:28 View
if(sizeof(void*) == 4 ) // 32 bit else(sizeof(void*) == 8 ) This is NOT correct way to determine if OS is 32-bit or 64-bit. It is the bitness of your application, which is defined at compile time!
Ajay Vijayvargiya - 27 Sep '10 - 22:58 View
char buffer[10]; // Global ... // thread 1. int n1 = atoi(buffer); // thread 2 int n2 = atoi(buffer); Isn't it thread-unsafe? This is the whole point. Unless you guard the function or the object yourself, it is unsafe!
Ajay Vijayvargiya - 27 Sep '10 - 15:07 View
Program code, user forms, database, sorting searching, multithreading, printing.. you need everything to implement - my sixth sense says. Come on, please explain more about it.
Ajay Vijayvargiya - 27 Sep '10 - 14:58 View
Funny answer: int n = 2^999; is valid! Serious question: Why do you need that?
Ajay Vijayvargiya - 27 Sep '10 - 14:53 View
Your question is well answered, this is about disabling C++0x, and other VC10 stuff. Just change the compiler toolset (in project properties), from v100 to v90. You *must* have VS 2008 installed.
Ajay Vijayvargiya - 27 Sep '10 - 14:39 View
See if EM_SETCUEBANNER message-code is available for your code. This is due to macros described by Sauro above. Ensure you defined those macros BEFORE anything else in your code/project.
Ajay Vijayvargiya - 25 Sep '10 - 4:40 View
Reason for my vote of 1 This is not alternate. You should have commented, not given it as alternate
Ajay Vijayvargiya - 22 Sep '10 - 10:19 View
I believe they are not common among Windows and/or MFC programmers. Thus, I have not added it. Also, putting them would require this Tip/Trick to be longer (Article would fit). I also believe that anyone using BSTR/ComBSTR knows well about ANSI/Unicode stuff.
Ajay Vijayvargiya - 19 Sep '10 - 16:56 View
If using C++: IntPtr is not available in C++. Rather sizeof(int) does the same. Nonsense, int is always 4-bytes, on 32-bit AND on 64-bit. Windows implements LLP64 model for 64-bit architecture.
Ajay Vijayvargiya - 19 Sep '10 - 16:52 View
Reason for my vote of 1 This alternate is absurd and should be removed immediately. The 32-bit native image generated always say 32, and 64-bit will always say 64. The sizeof is NOT runtime defined, it is ALWAYS compile time!

Advertise | Privacy | Mobile
Web03 | 2.6.130523.1 | Last Updated 1 Jan 1900
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid