Click here to Skip to main content
15,302,979 members

Comments by Sauro Viti (Top 197 by date)

Sauro Viti 18-Jun-13 4:21am View
TCHAR is always the best choice as it make your application Unicode-aware.
It is just a typedef that translate to char when _UNICODE is not defined and to WCHAR otherwise.
To use the TCHAR datatype you should include the tchar.h header.
Sauro Viti 29-Jan-11 17:03pm View
Reason for my vote of 5
Useful trick!
Sauro Viti 25-Jan-11 4:31am View
"It is not wise to throw exception" - Really? It's strange because the C++ standard say the opposite, and the exception handling is considered an important and required feature of modern object-oriented programming languages.

Obviously, if you are writing software for an embedded platform, with limited resources or with very strict constraints about performances, you could be right (but probably you won't use C++, but plain C instead).

Generally speaking, the little overhead of the exception handling is not perceptible and doesn't affect the application performances; then using exceptions give you the chance to write code which is easier to write, to maintain and that others could better understand.
Sauro Viti 21-Dec-10 16:48pm View
Ah ah ah! Good idea! But google has already done it!
Sauro Viti 1-Dec-10 15:41pm View
I updated my answer to make clear how the scalar and vectorial products are used in the angle evaluation. I hope it's understandable now :-)
Sauro Viti 1-Dec-10 7:35am View
atan2 is not the inverse tan(theta); its signature is atan2(y, x) and it gives the angle (in radians) whose sin is y and whose cosine is x (it works properly also if both x and y are scaled by the same constant).
For more details see
Sauro Viti 1-Dec-10 6:20am View
Good call!
Sauro Viti 1-Dec-10 6:16am View
Why do you want to modify the vtable of an object? Sincerely, I'm not able to imagine what does the possibilities are...
Sauro Viti 30-Nov-10 9:36am View
Why did you post again your question as it is an answer?
Sauro Viti 30-Nov-10 9:35am View
Don't post fake answers. To add details to your question use the "Improve question" link below it.
Sauro Viti 25-Nov-10 5:30am View
I'm sorry, but be aware that MFC is a quite huge and intrusive framework: to get a statically linked executable of 1.60 MB is not a bad result... If you really need a very small footprint you should consider using a different approach. You could try the WTL (Windows Template Library): its based on ATL and share a quantity of classes with MFC (like CString, CList, CMap, etc.).
Porting your application to WTL could require a while, but the result in terms of size will be great.
Sauro Viti 25-Nov-10 5:10am View
My vote of 2: well, this is a fake answer and deserves a vote of 1, but the target of the author is to thank others, so I upvoted for the good intention...
Sauro Viti 23-Nov-10 7:06am View
Well! Probably you have a worker thread that does some kind of work while your window is shown: from that thread you can post a user-message to your window and on the message handler of the window call EndDialog.
Another, very unelegant, option is to set up a timer in your window and periodically test for your conditions: if the conditions are satisfied call the EndModal.
If you don't need the value returned by DoModal, simply ignore it (anyway you should specify something when calling EndDialog, for instance IDOK).
Sauro Viti 19-Nov-10 15:20pm View
My vote of 1: the AES algorithm is on the public domain! What you need is just googling a bit and you'll get the full source code already done!
Sauro Viti 15-Nov-10 12:58pm View
My vote of 1: Not only you are too lazy to try doing your job by yourself, but you are too lazy to explain what are you talking about in an understandable way!
Sauro Viti 15-Nov-10 11:34am View
Yes, it could
Sauro Viti 12-Nov-10 14:47pm View
Be aware that if you use a shared section on a DLL, all the clients of the DLL will share that section as long as the library doesn't get relocated while loaded. In other words, if your service loads the DLL at address x and another of your app loads the library at address y, the two applications will really share the data only if x == y.
Sauro Viti 11-Nov-10 16:33pm View
Reason for my vote of 5
Well done! Just an improvement: you could use the complex header and handle the case of determinant < 0 giving complex radixes...
Sauro Viti 11-Nov-10 15:52pm View
Please, do not insist: no one will do your assignment for you!
First try by yourself, then is you have problems came back here, show your effort, describe what doesn't work as you expected and add a snippet of the relevant code.
People will be more than happy to help this way!
Sauro Viti 5-Nov-10 7:50am View
Toolbars doesn't use icons: they use an image-list (see CImageList on the MSDN for more informations) which are based on a single bitmap that holds multiple images indexed starting from zero (for example you can create an image-list attaching a bitmap which is 64x16 pixel and holds 4 images 16x16 pixel each one)
Sauro Viti 4-Nov-10 13:05pm View
As he assigned j = Int32.MaxValue the only chance to not overflow on the product is to get 1 as random number...
Sauro Viti 4-Nov-10 9:13am View
You make me doubt! It 's been so long since I studied books on C!
Sauro Viti 31-Oct-10 7:21am View
No one excepted me! Ahahahahah! ;-)
Sauro Viti 29-Oct-10 15:41pm View
Reason for my vote of 1
What a terrible and insane idea!
PS: you cannot compare this with the partial classes of C#, as C# doesn't distinguish between declaration and implementation. Anyway, the only one use that I have seen of partial classes is to keep separate user code from the code generated by the designer!
Sauro Viti 29-Oct-10 14:25pm View
Rajesh is somehow trying to give an help, then I counter-voted 5
Sauro Viti 29-Oct-10 4:33am View
The size of icons shown on the desktop is a setting of the desktop, then you cannot have your application icon to be shown as 48x48. What you can do is to change the desktop settings, but doing this all the icons on the desktop will be 48x48
Sauro Viti 28-Oct-10 15:41pm View
It's very strange: the code seems to be right! Have you tested the HRESULT returned by GetMixingPrefs and SetMixingPrefs? They both should be S_OK if there are not been errors.

PS: Don't post comments as new answers...
Sauro Viti 28-Oct-10 12:09pm View
Thank you Nishant :-)
Sauro Viti 27-Oct-10 9:13am View
Look at the code: he copied the entire content of the std::vector to a standard C-array and then he used that one...
Sauro Viti 27-Oct-10 8:31am View
This is not an answer. To add comments use the "Add Comment" link
Sauro Viti 27-Oct-10 5:48am View
What are you proposing for 8 to 32 bit conversion doesn't work: if the 8 bit image is a grayscale one, you have to set for each pixel the alpha channel to 255 and red = green = blue = the value of the byte on the source. If the 8 bit image is a colour image with palette, you have to lookup each value in the palette to get the correspondant RGB values.
Sauro Viti 27-Oct-10 3:51am View
Really, I don't understand why someone voted this question 1 or 2
Sauro Viti 27-Oct-10 3:40am View
No effort
Sauro Viti 26-Oct-10 10:33am View
1) Data_Of_Thread_1 is a pointer to a struct named data_files, then is not the right type to be passed to ExitProcess: you can write "ExitProcess(0);" and it will work, but you cannot write "ExitProcess(Data_Of_Thread_1);" because the compiler give you an error.
2) If you call ExitProcess from within your threads (1 and 2), when the first of the two end its task, the entire application is terminated
Sauro Viti 26-Oct-10 7:53am View
ExitProcess wants a DWORD with the exit code that should be returned by the application. You don't have to call it from your worker thread, as it terminates the whole application.
Sauro Viti 26-Oct-10 6:20am View
Fortunately the quality of answers is not related to the quality of questions...
Sauro Viti 26-Oct-10 4:25am View
Reason for my vote of 4
Good start, but not complete: if the application is compiled for 32 bit, Is64BitOs return true on 64 bit OS and false otherwise. If the application is compiled for 64 bit (and then could run only on 64 bit OS), the function Is64BitOs returns false.
Sauro Viti 26-Oct-10 2:54am View
Reason for my vote of 2
Not true. See iberg comment.
Sauro Viti 26-Oct-10 2:45am View
Please, don't post fake answers; add your comments to existing answers instead...
Sauro Viti 25-Oct-10 6:22am View
Reason for my vote of 1
This is false: it gives the bitness of your application. Not the operating system.
Sauro Viti 22-Oct-10 6:18am View
No effort
Sauro Viti 22-Oct-10 2:32am View
Reason for my vote of 5
You are right, I hadn't read with enough attention! I removed my duplicate tip!
Sauro Viti 21-Oct-10 12:12pm View
Your question is not clear. You should better explain what are you trying to do...
Sauro Viti 21-Oct-10 12:09pm View
Assuming that it is useful, you should simply use the keywords provided by the language. A macro that expands to only one keyword and nothing else, is only a way to obfuscate the source code and make harder to understand it for others.
Sauro Viti 21-Oct-10 11:58am View
It's C++, but used in a bad way...
Sauro Viti 21-Oct-10 8:56am View
How this is related to the question?
Sauro Viti 21-Oct-10 8:25am View
Reason for my vote of 5
Wonderful: an elegant and powerful solution!
Sauro Viti 21-Oct-10 8:13am View
I understand your requirement! Unfortunately this means that probably you should do it in the hardest way (i.e. writing your code to handle the PE format); however I found some link that could be useful (see my updated answer)! Good luck!
Sauro Viti 20-Oct-10 17:24pm View
The last sentence on your answer deserves a 5!
Sauro Viti 20-Oct-10 17:11pm View
1) The getch() function is deprecated; use the _getch() instead
2) Look at the documentation of _getch() at
It says: "When reading a function key or an arrow key, each function must be called twice; the first call returns 0 or 0xE0, and the second call returns the actual key code."

Now, try this:

printf("Press F1 key to continue.\n");
while (true)
int c = _getch();
if (c != 0x00 && c != 0xE0) continue;
if (_getch() == 0x3B) break;
Sauro Viti 20-Oct-10 16:43pm View
No effort made, neither in writing the question in a decent way
Sauro Viti 19-Oct-10 11:01am View
Don't post your e-mail address unless you'd like to get spammed...
Sauro Viti 19-Oct-10 3:54am View
Please, don't post fake answers
Sauro Viti 18-Oct-10 13:29pm View
There is always something to learn from the answers of Ash :-)
Sauro Viti 18-Oct-10 10:57am View
Not only: what sense could have a virtual constructor??? The constructor is called when instantiating an object, but who write the code must know which kind of object to instantiate!
Sauro Viti 18-Oct-10 8:48am View
don't post fake answers
Sauro Viti 18-Oct-10 3:11am View
Please, wrap your code into PRE tags: it will be too much more readable!
Sauro Viti 15-Oct-10 5:28am View
Please, use the PRE tags to improve the readability
Sauro Viti 14-Oct-10 9:39am View
Ops, sorry! Try this:

row.ItemArray = new object[1];
row.ItemArray[0] = (object)obj1;
Sauro Viti 14-Oct-10 8:18am View
Look at the guidelines about posting a question: "3.Keep the subject brief but descriptive."
Your subject doesn't tell us nothinganything about your problem, and also it's not an interesting question.
Sauro Viti 14-Oct-10 6:49am View
Yes, this is his problem... pheraps he had choosen the wrong work...
Sauro Viti 14-Oct-10 4:45am View
No effort
Sauro Viti 14-Oct-10 4:41am View
Sorry, but I don't agree with you: to test "x < 20" or "20 > x" is absolutely the same. What you are talking about is "x <= 20" which is the same than "21 > x"; or implementing "x < 20" as "!(x >= 20)".
Sauro Viti 14-Oct-10 4:09am View
No effort
Sauro Viti 13-Oct-10 11:59am View
Reason for my vote of 5 - It's the most sympathetic answer!
Sauro Viti 13-Oct-10 8:27am View
Good answer, however I think there is a too much trivial solution:

if (20 > x) // Same than x < 20 but using the greater than operator!
b = y + f;
b = y;
Sauro Viti 13-Oct-10 5:45am View
Your question is not clear; I suppose that you want to use Javascript as embedded scripting language inside a VC application. Isn't it?
Sauro Viti 8-Oct-10 16:47pm View
From the site that I give you download the source files zip; inside it you also find the instructions on how to build it... if I remember right :-)
Sauro Viti 8-Oct-10 9:58am View
That character is part of the extended ASCII set, if you prefer you could also hold the ALT key and type 253 on the numeric pad (its ASCII code is 253).
Sauro Viti 8-Oct-10 8:28am View
I think that just only one 5 doesn't balance a vote of 1: it's a good answer then I give you my 5 too!
Sauro Viti 8-Oct-10 6:04am View
The web site you are working on is realized using plain HTML? From what you are saying, I suspect that there is an embedded object in the web page, for instance a flash player application, and that such object do the job programmatically (for instance getting the informations to show from a database connection).
Try this: open the web page on your browser and save it to your HDD as HTML file (you get too a folder with all the objects embedded in the page). Then open the HTML file with notepad and have a look for its structure.
Sauro Viti 7-Oct-10 8:27am View
PPPS: Today optimizing compilers are able to produce a so deeply optimized code, that is very hard to do better by hand. Then, in the most of cases, is too much better to forget the __asm keyword, write everything in C/C++, and let the compiler do the job!
Sauro Viti 7-Oct-10 4:59am View
From your posts, I suspect that there could be a little misunderstanding: the Visual C++ could target both native and .NET environments. Which one are you interested in?
If you use C++/CLI (i.e. the .NET version), any library built for C# is also good for it: you only have to add a reference to the assembly in your project to use the library (with a syntax just a bit different from C#).
If you are using MFC (then in a native environment), you need a native version of the library, and how to include and use it in your project is quite different than the C# and C++/CLI way.
Sauro Viti 5-Oct-10 1:16am View
Cool answer! Well said! :-)
Sauro Viti 4-Oct-10 2:51am View
Yes, I can, but I will not! This is a simple 2nd degree equation: why don't you do your homework by yourself?
Sauro Viti 4-Oct-10 2:50am View
Math.Sqrt compute the square root, then Math.Sqrt(x - a) is not the same than Math.Pow((x - a), 2)
Sauro Viti 1-Oct-10 4:33am View
In MMX intrinsics I don't know about operations that involve a vector and a scalar, then I think you have to initialize three__m64 variables for the Adjust, _f and _scale and initialize them with the right values (i.e. with all the 4 fields equals to your current scalar value)
Sauro Viti 30-Sep-10 7:49am View
I think you have to implement:
block[j] = (1 - (x0 >> 15) * 2) * (((1 - (x0 >> 15) * 2) * x0 * Adjust[_qm] + _f) >> _scale)
where x0 and block[j] are vectors and all the others are scalar values
Sauro Viti 30-Sep-10 5:29am View
do you know the difference between C# and C++/CLI? Pheraps you need to change the tags on your question...
Sauro Viti 29-Sep-10 10:38am View
Uhmmm... Pheraps are you asking about the Windows Event Logs (the ones that you can browse with the Event Log Explorer which is under Administrative Tools in the Control Panel)? If the answer is yes, the documentation that you need is located at
Sauro Viti 29-Sep-10 8:32am View
Just a little improvement... As the arrays could be not initialized, to avoid exceptions change the if statement inside the for loop as follow:

if (jaggedarray[i] != null && jaggedarray[i].Length > max)
max = jaggedarray[i].Length;
Sauro Viti 29-Sep-10 6:16am View
mhmm... are you sure? I think it should be (cos(B) - X1/X2) / sin(B) = (cos(B) - (X1/X2)) / sin(B)
Sauro Viti 29-Sep-10 5:59am View
Mi fa piacere! Grazie!
Sauro Viti 29-Sep-10 5:32am View
Yes, it is! tg stays for tangent and arctg stays for arc-tangent (i.e. inverse tangent).

Sauro Viti 28-Sep-10 11:14am View
With SSE instruction set enabled, is possible that the compiler itself unroll your non-MMX version using SSE... Try to disable the SSE instruction set ;-)
Sauro Viti 27-Sep-10 15:02pm View
When using precompiled headers, the right place where put them is in the head of the stdafx.h file...
Sauro Viti 27-Sep-10 15:01pm View
The manifest seems to be right, however problems with the manifest could generate errors at runtime. Problems at compile time like undefined symbols are commonly due to wrong usage of the Windows headers. If you are using precompiled headers check for the defines I wrote above in your stdafx.h
Sauro Viti 27-Sep-10 4:10am View
Don't post question as answer; to add details to your question, use the "Improve question" function!
Sauro Viti 27-Sep-10 4:06am View
Please, use PRE tags to improve code readability
Sauro Viti 24-Sep-10 11:05am View
I'm with you! It's easier to use TryParse than handling an exception; I proposed the try/catch mechanism but only because it allow to distinguish between overflow and other failure reasons.
Sauro Viti 23-Sep-10 12:54pm View
The CloseHandle function wants as parameter just one handle, the one that you want to close. If you don't close the handles, the created threads remain allocated also after their termination, and you risk resource and memory allocation problems (the number of thread a process can create is limited by the available virtual memory). Then you can write something like this inside your while loop:

HANDLE hThread = CreateThread(NULL, 0, functionAddress, parameters, 0, NULL);
if (hThread != NULL) CloseHandle(hThread);
else { /* Thread creation error! */ }
Sauro Viti 26-Aug-10 5:27am View
This is something commonly used in COM programming, where methods return an HRESULT to report about failed/succeeded, and the "real" output of calls are obtained through parameters passed by address, like this:

HRESULT IUnknown::QueryInterface(REFIID riid, void **ppvObject);

However, I think that generally speaking, this is an unelegant solution and it's better to return a struct or class...
Sauro Viti 25-Aug-10 10:24am View
Other useful informations are:
is Vista 32 or 64 bit?
is Xp 32 or 64 bit?
do you compile for 32 or 64 bit target?
Sauro Viti 25-Aug-10 7:04am View
"Loop unrolling" and "make the code small" point to the opposite directions... ;-)
Sauro Viti 25-Aug-10 5:29am View
Use the PRE tags to enclose your code snippets: they make them more readable
Sauro Viti 24-Aug-10 5:10am View
Reason for my vote of 5
Good answer
Sauro Viti 17-Aug-10 5:37am View
Don't post your e-mail on public forum: you only get spammed! ;-)
Sauro Viti 17-Aug-10 5:31am View
Reason for my vote of 5
Very good: the use of STL make the code short, safe and easy to understand
Sauro Viti 12-Aug-10 11:01am View
On Visual Studio the pre-build step is executed before than compiling and linking steps, then you have to put the command for executing your script in the pre-build step command line.
This way your script is executed each time you build or rebuild your project; after that all the files in the project are compiled, then all includes are processed properly.
Sauro Viti 11-Aug-10 5:07am View
Just a little thing: you said "if you need some OS API, you must import dinamically the operating system DLL (via LoadLibrary and GetProcAddress)", but to do it you should use LoadLibrary and GetProcAddress, then you should link against kernel32.lib
Sauro Viti 11-Aug-10 5:05am View
Reason for my vote of 5
Good answer
Sauro Viti 9-Aug-10 2:36am View
Yusuf, I think that E.F. Nijboer was talking about C++/CLI: the same API is available to all the languages that support the .NET Framework
Sauro Viti 9-Aug-10 2:20am View
why did you define a function inside another one? in C/C++ is illegal: remove the add() function and I think that everything will go ok!
Sauro Viti 6-Aug-10 14:22pm View
As that function is not declared as inline, you should place it in a .cpp file: if you place it in a .h file and then you include the header from more than one .cpp file ou will get warnings/errors while linking
Sauro Viti 6-Aug-10 11:14am View
:-O Thank you Richard! It's 2^99999 that in binary is 1 followed by 99999 zeroes!
Sauro Viti 6-Aug-10 10:58am View
Reason for my vote of 5
Really a good approach to the problem!
Sauro Viti 6-Aug-10 10:07am View
Ok, I'm wrong because technically speaking it's possible, and you know that doing it is a very bad approach.
You say "I know. I don't do this. jaiant812 want to do it.", then if someone say "I want to commit suicide" a good answer is "buy a gun"? Obviously this is an exaggerate example, but this is the reason of my vote 1: to be a good answer you should specify "you can do it this way, but it's not advisable because...", so that the enquirer could really learn about OOP.
Then we both deserve a bad vote! ;-)
Sauro Viti 6-Aug-10 8:45am View
Wow! What a great idea! Encapsulation and polymorphism are two basics on OOP! If an enquirer ask about how to break them a wise developer should suggest him to avoid it and why, not simply tell him how to get in trouble!
Sauro Viti 6-Aug-10 8:32am View
Reason for my vote of 1
Your solution works as long as the method has not been declared as virtual.
Anyway doing that is a bad programming technique and it breaks the principles of OOP.
The C# compiler allow you in doing it, but it give you a warning (CS0108) if you redefine a method that is not virtual without using the new keyword.
Sauro Viti 6-Aug-10 7:44am View
This way:

void DoSomethingWithSSE2(int *btr)
// btr is an address passed on the stack, the parameter address could not be aligned...
__declspec(align(16)) int *b = btr; // This way the address of b is aligned!

void main()
// The array should be aligned for use with SSE2
__declspec(align(16)) int array[4][4] = { ... };

Sauro Viti 6-Aug-10 6:02am View
Reason for my vote of 1
No effort, asking for code
Sauro Viti 6-Aug-10 4:40am View
I think that the enquirer doesn't want to call base.Method() from "inside" the derived class...
Sauro Viti 5-Aug-10 11:10am View
your mood today is definitely variable!
Sauro Viti 5-Aug-10 9:47am View
Reason for my vote of 1
Don't re-invent the wheel: the DropDownStyle already exists for this task
Sauro Viti 5-Aug-10 9:33am View
Reason for my vote of 5
Well said!
Sauro Viti 5-Aug-10 6:08am View
To use your e-mail address as nickname is not a good idea, unless you like receiving spam!
Sauro Viti 5-Aug-10 3:17am View
Reason for my vote of 1
I agree with Toli
Sauro Viti 5-Aug-10 1:27am View
To access the base class method you should write:
BaseClass obj = new BaseClass();
If you mean "how to access the BaseClass version of the method on a child class" the answer is:
1) from inside the child class use base.Test();
2) from outside the child class is not possible
Sauro Viti 4-Aug-10 18:08pm View
I open windows.h on my PC, it is just about 250 lines, and in the middle of it I found:

#include <windef.h>
#include <winbase.h>
#include <wingdi.h>
#include <winuser.h>

The errors that you are experiencing are due to the types HDWP, MENUTEMPLATEA, LPMENUTEMPLATEA, CALLBACK and WNDPROC that are undefined: theys typedefs are inside windef.h and winbase.h
Sauro Viti 4-Aug-10 17:45pm View
windows.h includes automatically winuser.h and it do it using the right sequence of includes required to make it work... please, try it!
Sauro Viti 4-Aug-10 4:29am View
And where is the code?!?
Sauro Viti 4-Aug-10 4:26am View
Reason for my vote of 5
Good answer!
Sauro Viti 4-Aug-10 4:21am View
Reason for my vote of 1
see what digital man wrote!
Sauro Viti 3-Aug-10 10:52am View
Reason for my vote of 1
1. No effort
2. Demanding full code
Sauro Viti 3-Aug-10 8:39am View
Pay attention to the tags you set for your questions: here C++ means "C++ language compiled to native machine code". Since you are experiencing a problem related to C++ with .NET Framework, is too much better to tag your question as C++/CLI
Sauro Viti 30-Jul-10 9:27am View
Message queues are not part of the ANSI C language: they are a kind of IPC but the implementation depends on the operating system and/or any other external library. Then first you need to set a target platform, identify the library to use, and study its API. Sorry, but I cannot tell you more than this...

PS: Pheraps you can start from these links (for Microsoft Windows) (for Unix like OS)
Sauro Viti 30-Jul-10 3:19am View
I saw the same question from you in the C/C++/MFC forum. Please, don't post the same question to multiple forums.
Sauro Viti 29-Jul-10 15:11pm View
If you add an handler of this kind, it will be called each time the check-box is clicked, however to retrieve the checked-unchecked status of it you should use one of the methods that I wrote. You can also keep trace of the checked-unchecked status using a BOOL variable and toggling it each time the handler is called, but this is a very bad solution (for instance if you change the check-box status programmatically the handler is not called and you have to treat this case separately).
Sauro Viti 29-Jul-10 11:11am View
To translate byte values to their hexadecimal representation you can use sprintf(buffer, "%02X", value); the format string "%02X" mean: format in hex using two digits and fill with zero on the left (then if value = 0x01, inside buffer you obtain "01")
Sauro Viti 29-Jul-10 2:37am View
Reason for my vote of 1
1. Demanding
2. No effort
Sauro Viti 28-Jul-10 14:54pm View
Reason for my vote of 1
asking for complete source code, for a complex work, without showing any effort and it's urgent too!
Sauro Viti 28-Jul-10 5:19am View
Reason for my vote of 5
Very useful information
Sauro Viti 26-Jul-10 10:37am View
1. Don't write all uppercase and/or bold: it is intended as shouting.
2. Don't publish your e-mail here, you will only get spammed.
Sauro Viti 26-Jul-10 9:07am View
Reason for my vote of 1
1. homework
2. no effort made
3. ask for code
Sauro Viti 26-Jul-10 4:08am View
Yes, you are right; I show this example to point out that the compiler resolve the method to be called without regard to the returned type
Sauro Viti 25-Jul-10 10:36am View
Reason for my vote of 1
see the answers
Sauro Viti 23-Jul-10 10:34am View
Note that 32 is represented in binary format as 00100000 so you could translate to uppercase/lowercase using bitwise & and | operators... Who initially design the ASCII code did it in a clever way!
Sauro Viti 23-Jul-10 7:06am View
Yes, it is: if your DLL doesn't implement DllUnregisterServer then the only way to unregister it is to know all the entries in the Windows registry that you should manually remove (and it is a nightmare).
Since you have the source code, the best is to add the DllUnregisterServer to your library, compile it again and then call regsvr32 /r filename.dll
Sauro Viti 23-Jul-10 6:19am View
Reason for my vote of 1
1. homework
2. no effort made
3. ask for someone doing his work
Sauro Viti 23-Jul-10 5:03am View
Reason for my vote of 5
Very good answer! Today cheeseburger and french fries for everyone!
Sauro Viti 23-Jul-10 3:30am View
Don't post comments as answer; use the "Add comment" link instead
Sauro Viti 22-Jul-10 17:12pm View
Reason for my vote of 5
I agree with you, but which is the right career for a lazy man?
Sauro Viti 22-Jul-10 12:59pm View
Reason for my vote of 1
not a question: it's advertising
Sauro Viti 22-Jul-10 10:52am View
Reason for my vote of 5
this is really the only possible answer!
Sauro Viti 22-Jul-10 10:07am View
From what he said, I think it is just a little application (probably homework) written in ANSI C/C++
If I'm wrong I really don't imagine how it's possible that he could compile his code on both the OS!
Sauro Viti 22-Jul-10 9:45am View
OpenCV is an open-source library, then he could get the source code and extract some functions, but I think that it is absolutely not a good idea
Sauro Viti 22-Jul-10 7:04am View
To do it you should compile your application with CLR; add the using statement is not enough. Search about using CLR and MFC together; however I think it's better if you use a lightweight regular expression library for C++, as the one that _Superman_ suggested you.
Sauro Viti 22-Jul-10 7:00am View
Reason for my vote of 5
precise and definitive answer. no more details are needed
Sauro Viti 22-Jul-10 5:43am View
Don't post comments as answer; use the "Add coment" link instead
Sauro Viti 22-Jul-10 5:38am View
Be more specific, give your question a title that explain what is the matter.
What do you want to do? What have you tried?
Sauro Viti 22-Jul-10 3:09am View
Reason for my vote of 1
1. code request
2. no effort made

here you find people that help you with specific problems, but you must make an effort and write down your code!
If you want someone else to do the job for you try to post a job offer...
Sauro Viti 21-Jul-10 17:02pm View
Reason for my vote of 1
1. no effort made
2. just ask for code
Sauro Viti 21-Jul-10 17:01pm View
Reason for my vote of 1
see reason for Sandeep Mewara's vote of 1
Sauro Viti 21-Jul-10 15:12pm View
I saw ITNOG some days ago and I made some search... It seems to stand for "In The Name Of Glory" or "In The Name Of God"
Sauro Viti 21-Jul-10 8:22am View
Reason for my vote of 1
no effort made
Sauro Viti 20-Jul-10 10:26am View
Reason for my vote of 1
No effort made
Sauro Viti 20-Jul-10 5:07am View
Please, don't post a comment as an answer; use the "Add comment" link below the answer instead
Sauro Viti 20-Jul-10 4:07am View
Sorry, but I don't understand what the question is... It seems that you want to post your message to a specific member...
Sauro Viti 19-Jul-10 9:31am View
I had searched a bit... It seems that ITNOG stands for "In The Name Of Glory" or "In The Name Of God" :-)
Sauro Viti 19-Jul-10 3:01am View
Dear Varun,
I'm very sorry that what I said is not of help for you. Unfortunately that is all I know about HASP HL devices; I used it to protect an application of my company, but our protection scheme is quite simple so I didn't need to investigate more.

Sauro Viti 16-Jul-10 5:03am View
Use <PRE> tags to improve code readability
Sauro Viti 14-Jul-10 13:51pm View
For a better look and to make it more readable, please wrap your code in a <PRE> block
Sauro Viti 14-Jul-10 13:49pm View
The error list display compile and link errors! What John mean is: run your application under the debugger, place a breakpoint at the beginning of your Delete() method, then proceed step-by-step and watch variables, files, etc. to understand what's happening
Sauro Viti 14-Jul-10 11:12am View
This is not an alternate! You should post your comments in the right place (using the Add Comment link under the original post)
Sauro Viti 14-Jul-10 5:48am View
Have you ever known people from a culture different from your? Just for your information, the english humor is not the only one and lot of cultures doesn't understand it and/or doesn't like it!
Sauro Viti 14-Jul-10 5:13am View
Reason for my vote of 1
Offensive and mannerless
Sauro Viti 14-Jul-10 2:45am View
It is possible that the DLL you are using keep trace of allocated memory and free it on its DllMain when it is called with DLL_PROCESS_DETACH reason. However the standard behaviour of DLL on Windows is the one that Nishant already said.
Sauro Viti 14-Jul-10 2:41am View
It's not a good idea to share your e-mail on a forum with millions of people: you have a few chance to get what you expected but a great chance to get spammed!
Sauro Viti 13-Jul-10 12:01pm View
The compiler automatically cast float values to double and then pushes two dwords in the stack: each float can be represented with a double and the cast overhead is about one CPU clock cycle in the worst case.
Sauro Viti 13-Jul-10 8:40am View
Console.WriteLine() is designed to write to the window of console applications. Try this: start a new project of type "Console application" and mix Console.WriteLine() and System.Diagnostic.Trace.WriteLine(). As result, the first will write to the console window (the one like Command prompt) and the second one write to the debugger output window.
Simply you are using that function in a way that is not the correct one, and you obtain unexpected/strange results.
Sauro Viti 13-Jul-10 8:22am View
Io sono di Prato, ma lavoro a Calenzano (FI)
Sauro Viti 13-Jul-10 3:00am View
You are using an anonimous delegate from which you call your function. You should try/catch the ThreadAbortException at the most external level, then you should do it inside your delegate, like this:

thrDownload = new Thread(new ThreadStart(
downloadFile(txtServerIP.Text, txtFileName.Text, txtUsername.Text, txtPassword.Text);
catch (ThreadAbortException ex)
MessageBox.Show("Download aborted");
Sauro Viti 13-Jul-10 2:51am View
Allora in bocca al lupo per il tuo progetto! Di dove sei?
Sauro Viti 12-Jul-10 16:07pm View
Ok, this is not homework... But what is the question? You should show us what you have done and what doesn't work as you expected!
Sauro Viti 12-Jul-10 16:03pm View
Let's say: if the most of your application is written using ANSI C/C++ and you need just a few number of functions that are platform dependant, you can define a function for each platform-dependant feature that you need, and in the implementation of the function use #ifdef to achieve the goal using API that are specific to each platform (#ifdef WIN32 for Windows and so on).
If your application is a GUI (windowed) one, then this is an hard job because you are using a lot of API specific to the operating system. However how many chances there are that while the application grow you don't need other stuffs that are platform specific? And again, on Linux you have mount points, not drive letters... You need to consider each aspect of your application in a cross-platform scenario before choosing a way to solve your problem.
Sauro Viti 12-Jul-10 5:14am View
When you want to add a comment to an answer, or a comment from someone else, don't use the "Add your answer here": this way you'll get an e-mail that notify you about a new answer to your question. Instead use the "Add comment" link below the answer/comment: this way who write it will receive an e-mail with your comment...
Sauro Viti 12-Jul-10 3:15am View
Reason for my vote of 1
He doesn't show any effort in finding solutions and conding: just a list of what he want to do. It smells like homework.
Sauro Viti 6-Jul-10 3:46am View
What you want to do seems to be clear, then what is your problem?
Sauro Viti 23-Jun-10 16:54pm View
It works not only in Visual Studio 2010 but in 2005 and 2008 too.
Sauro Viti 23-Jun-10 16:49pm View
Ops! I absolutely agree with you!
Sauro Viti 10-Jun-10 20:01pm View
very well! so good luck for your end-of-college exam!
Sauro Viti 10-Jun-10 18:54pm View
No problem! I hope it works properly now... had you wrote 41 instead than 0x41?
Sauro Viti 10-Jun-10 15:48pm View
Reason for my vote of 1
Here's a tip for your next Tip/Trick: Don't post garbage that you get from some anonymous website
Sauro Viti 10-Jun-10 15:23pm View
I think that there is something wrong!Have a look to the page I posted about SetWindowsHookEx, on the Remarks section about LowLevelKeyboardProc callback, they says:

"This hook is called in the context of the thread that installed it. The call is made by sending a message to the thread that installed the hook. Therefore, the thread that installed the hook must have a message loop."

So, to work properly, the hook procedure must have been installed by a thread that handle a message loop, if your application is an MFC application the best place to put the call to SetWindowsHookEx is the constructor of your main window class. Note that worker threads and console applications do not have a message loop.

Just a style hint... why don't you write:

else if (pkbhs->vkCode == 'A') return 1;

instead than:

else if (pkbhs->vkCode == 41) return 1; // A
Sauro Viti 10-Jun-10 9:42am View
// This install the hook procedure (I suppose you are calling it from an MFC exe application)
hHook = SetWindowsHookEx(WH_KEYBOARD_LL, &LowLevelKeyboardProc, theApp.m_hInstance, 0);

// This is my hook procedure (it uses the KBDLLHOOKSTRUCT and it works properly...)
LRESULT CALLBACK LowLevelKeyboardProc(INT iCode, WPARAM wParam, LPARAM lParam)
if (iCode == HC_ACTION) {
BOOL bCtrl = GetAsyncKeyState(VK_CONTROL) >> (8 * sizeof(SHORT) - 1);
BOOL bShift = GetAsyncKeyState(VK_SHIFT) >> (8 * sizeof(SHORT) - 1);

if (pkbhs->vkCode == VK_ESCAPE && pkbhs->flags & LLKHF_ALTDOWN) return 1;
else if (pkbhs->vkCode == VK_TAB && pkbhs->flags & LLKHF_ALTDOWN) return 1;
else if (pkbhs->vkCode == VK_ESCAPE && bCtrl) return 1;
else if (pkbhs->vkCode == VK_LWIN) return 1;
else if (pkbhs->vkCode == VK_RWIN) return 1;
else if (pkbhs->vkCode>=VK_BROWSER_BACK && pkbhs->vkCode<=VK_LAUNCH_APP2) return 1;

return CallNextHookEx(hHook, iCode, wParam, lParam);
Sauro Viti 10-Jun-10 2:17am View
Via LPARAM is passed not the struct, but a pointer to the struct
Sauro Viti 9-Jun-10 16:06pm View
There are 2 possible scenarios depending on whether or not you have the source code of the set_game_name function that you'd like to "wrap":

1) if you have the source code you can modify the set_game_name function to get a va_list as parameter (i.e. set_game_name(const char *format, va_list args), like vprintf) or you can copy its code inside the body of your class member
2) if you don't have the source code you need to use inline assembler (to do that you must be experienced about C/C++ calling conventions, stack frame layouts, assembler and so on)
Sauro Viti 9-Jun-10 9:24am View
Reason for my vote of 1
Why don't you post something produced by you?
And, this is a site about programming! It looks like you just want to get reputation points!
Sauro Viti 9-Jun-10 7:12am View
Reason for my vote of 1
Your post is just a link to a web page where someone else (not you!) give some hint
Sauro Viti 9-Jun-10 6:59am View
Add a message handler for the BM_CLICK notification from your button (you can do it by double-clicking the button on the dialog-editor), then inside the message handler add code to show your dialog, like this:

CBrightnessDlg dlg(this);
if (dlg.DoModal() == IDOK)
// Do something
Sauro Viti 4-Jun-10 8:40am View
Reason for my vote of 1
Do your homework by yourself
Sauro Viti 4-Jun-10 2:47am View
Reason for my vote of 1
Sauro Viti 1-Jun-10 15:31pm View
Ops! I have not paid attention to the date! But what is .45 ACP?
Sauro Viti 21-May-10 6:14am View
Reason for my vote of 1
Unethical question...
Sauro Viti 19-May-10 10:34am View
Reason for my vote of 1
This is not an answer, but a list of hyperlinks to pages about "viagra"
Sauro Viti 17-May-10 17:30pm View
This is not the right place for your question. Retry following the hints below:

  • don't append your question to another one, but start a new question
  • give your question a significant title, then on the question body give a description of what you want do and a detailed description of the problem you are encountering
Sauro Viti 4-May-10 13:17pm View
:-) Hey! You are right! There is someone who like to do my homeworks?