15,666,902 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View Python questions
View Javascript questions
View C++ questions
View Java questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Andrew Brock (Top 149 by date)
Andrew Brock
17-Dec-11 20:47pm
View
Please justify your reasons. Are you trying to do something like google and index a website, or are you trying to do bad things?
Also, what should happen with the link? Should it open the link in the browser, or should it download that page and do something on it?
Use the "Improve question" button at the bottom of your message to update it.
Andrew Brock
13-Dec-11 7:37am
View
Blocking POST seems a bit silly, but there is no post data on the google homepage, so this shouldn't be an issue.
try adding a "www." in the url, see if that helps.
Another thing you can try is SSL, "https://encrypted.google.com" as the server. This encrypts your data and essentially bypasses the proxy and whatever content filtering it has since it cannot see any of the data, only that you are connecting to google.
All 3 URLs ("http://google.com", "http://www.google.com", and "https://encrypted.google.com") work on my computer, which has no proxy.
Andrew Brock
13-Dec-11 7:25am
View
Source code for MFC is included with Visual Studio for under <install dir="">\VC\atlmfc\src\mfc\ and for the CRT under <install dir="">\VC\crt\src\
There is no garbage collection in there, and C/C++ most defiantly does not provide garbage collection without using 3rd party libraries, or writing it yourself
That said, your answer is still the solution to the question, and is mostly right. 5'd.
Andrew Brock
20-Nov-11 3:17am
View
try replacing the 2nd last parameter, GetModuleHandle(NULL), with the hInstance which is passed into your WinMain() function
Andrew Brock
17-Nov-11 5:04am
View
How are you displaying it?
printf("%d") for int/long
if it is the debugger, right click on it and untick "hexadecimal display"
if it isn't any of these either tell me and I can tell you how do display in base 10, or consult the documentation
Andrew Brock
15-Nov-11 9:57am
View
I have had this code running on Windows 7, so if anything it would be a newer OS.
I don't imagine that is the issue tho.
If you haven't, try grabbing the source code and compiling it yourself, sometimes that helps.
If that fails, try posting a question to the original article with the location of the error. That way the author, the person who knows the most about it, will get the message and may be able to help you.
Andrew Brock
15-Nov-11 9:28am
View
The keyword "static" in this place means that the function GetHundredsWords() is only usable from within the .cpp file where the code is. In such a simple program it has no effect, since there is only 1 source file.
I use this notation for defining internal functions which should not be used by external code, in this example you would not use this function directly, you would just use GetWord()
Andrew Brock
15-Nov-11 4:45am
View
The main issue here is that C# uses managed Unicode strings, and C uses raw ASCII strings.
Andrew Brock
14-Nov-11 6:30am
View
It seems a bit silly, but is the compiler able to find the .tlb file?
Andrew Brock
14-Nov-11 6:29am
View
This is automatically negotiated with the device at the other end. It may be possible (although I don't know of any way) to force it to a slower speed, but the link cannot exceed it's maximum speed.
The data at the other end of the cable is not exactly what is sent. The quality of the cable can make it difficult to determine the original signal. You cannot force it to go faster than what it is capable of otherwise the devices can't tell what the original signal was.
Andrew Brock
14-Nov-11 6:16am
View
I cannot speak for all solutions, but Oracle xVM VirtualBox will not. It uses a network adapter driver to directly interact with the network connections on your computer.
Andrew Brock
14-Nov-11 6:08am
View
No it doesn't. See http://msdn.microsoft.com/en-US/library/b7w5x74z(v=VS.80).aspx
You can load up a bitmap however you want into a HBITMAP and shove that into it.
Andrew Brock
13-Nov-11 4:45am
View
I think this is what they are calling a "picture box", could be wrong tho.
Andrew Brock
13-Nov-11 2:59am
View
Can you please explain further (use the improve Question button at the bottom of your question).
Where are you trying to put the image? In a dialog box, on a button, around some text, ...?
Does "without using picture box" mean that you don't want to use a separate control to hold the image, if so, why, or what is stopping this approach?
Andrew Brock
13-Nov-11 0:26am
View
Are you using the Visual Studio compiler, or another one?
Also, can you provide at least the prototype of the function SetBcrPreset from the DLL code. The prototype should be
extern "C" void CALLBACK SetBcrPreset(int Unit, int Preset);
Andrew Brock
10-Nov-11 5:46am
View
By looking at the dataflow it seems that the C# library is sending additional parameters. The C++ server should recognise the connection (probably), but the c# client would not work. Try using the Socket class from http://msdn.microsoft.com/en-us/library/system.net.sockets.socket(v=vs.95).aspx
Andrew Brock
10-Nov-11 4:58am
View
You can process strings however you want in c++.
Andrew Brock
10-Nov-11 4:50am
View
What methods are you using in C#?
A standard TCP/IP socket created with WinSock will not discriminate language.
Andrew Brock
9-Nov-11 3:46am
View
This is technically possible, but could be a bit difficult to implement. Since you don't have Visual Studio, and hence don't have spy++ I have put an annotated screenshot at http://imageshack.us/photo/my-images/718/spyu.png/
Your code would have to find all windows with the class "CabinetWClass returned from the EnumDesktopWindows() function, and then follow all of the red arrows correctly to get the file path.
This was taken from Windows 7, I imagine Vista will be the same, but XP will be different, and this is where the issues arise. You will need to detect the OS and work from there.
Andrew Brock
9-Nov-11 1:57am
View
Be more specific. Are you trying to draw a circle region of a square image to the screen, or are you trying to do a 3D projection to make the square image look like it is a sphere, such as a map of the earth projected into a sphere?
Andrew Brock
9-Nov-11 1:40am
View
I would suggest using the Wavefront Object format (.OBJ) instead. This is the industry standard for sharing models and meshes. It is widely used, and there is no doubt a loader for it, see https://encrypted.google.com/search?hl=en&q=opengl+obj
It supports pretty much everything except for character animations, and Blender has both import and export scripts for it.
Andrew Brock
8-Nov-11 15:58pm
View
Take a look at http://msdn.microsoft.com/en-us/library/cd7a85k9.aspx
Andrew Brock
8-Nov-11 12:38pm
View
Do you understand the difference? I would love to see someone fail at explaining this in text. And we aren't going to just give you the answer to your homework.
Deterministic only has 1 possible next state from any given state. Draw this out as a bunch of circles and arrow, then figure out how to change it so that there is exactly 1 arrow coming from each circle.
Andrew Brock
8-Nov-11 12:06pm
View
VS2003 was the last compiler to support Windows 98. This is about the only reason I can think of, not that it makes sense.
Andrew Brock
8-Nov-11 12:04pm
View
I think that is just an example so we know what functionality they are after.
Andrew Brock
8-Nov-11 6:56am
View
Sorry, they are only supported by Visual Studio. It generates header files from the .tlb and .dll files. These headers then depend on the Windows SDK, and I am not familiar with Embarcadero, but since it is cross platform I suspect it does not support these headers (because that would no longer be cross platform).
You may just have to wait for someone else to make a suggestion.
Andrew Brock
8-Nov-11 6:17am
View
I forgot to mention that the names are in a valid internet format. This means that a space for example is represented as "%20" (the ascii code for a space is 32, which in hexadecimal is 0x20, hence %20). Some other characters are also in this format, you need to search for the % character and replace the next 2 characters which make up the hexadecimal code for the character with the character. Let me know if you need help with it.
Andrew Brock
8-Nov-11 4:16am
View
Plugins are usually written in C#. Added that as a tag so there is more chance of someone who knows what they are doing might see it.
I did write 1 a while back, that was somewhat similar to this, but the code must be on my backup drive. If no one has replied in a few hours I will dig that up.
Andrew Brock
8-Nov-11 2:39am
View
Do you mean jut in Windows explorer, or by any program, including cmd.exe and visual studio?
Andrew Brock
8-Nov-11 2:20am
View
This is done with the escape character, a singe backslash (\).
In a string this should be a double backslash (\\) because the compiler also takes this escape sequence, and converts that to a single backslash in the compiled code.
Andrew Brock
7-Nov-11 8:38am
View
Removed bold and email address.
No need to shout at people.
Unless you like spam, don't put your email address anywhere on the Internet.
Codeproject will send you an email automatically when someone replies.
Andrew Brock
7-Nov-11 7:49am
View
5'd. Forgot to mention that bit. Mention of a backup wouldn't go astray either.
Andrew Brock
7-Nov-11 6:41am
View
It is probably .NET
I have absolutely nothing to back that up, but it is how WP7 is programmed.
Andrew Brock
7-Nov-11 6:38am
View
Try putting the try/catch back, but do it as Mehdi suggests.
I suspect, however that it is not really this function causing the issue, but it is how you are calling it.
Could you please update your question to include the few lines of code preceding the function call.
You can browse the call stack by going to Debug>Windows>Call Stack. Double click on a function in the list to go to it.
Andrew Brock
7-Nov-11 6:20am
View
It took me a bit to get that too (see my comment to the original question). The code does look a bit messy
Andrew Brock
7-Nov-11 6:08am
View
Your answer is correct, it just isn't relevant to this question.
The 2 functions both non-const (also the 2 in the Tester struct), they just take a different argument, either of a const or a non-const function. It is the function which he is passing in as a parameter that has the const/non-const.
His code is perfectly valid and makes sense (although I don't imagine it is particularly useful for most scenarios).
What I said in my answer is still correct, and since it was marked as the solution I imagine it fixed the issue.
Andrew Brock
7-Nov-11 5:33am
View
This may be a limitation of the Express compiler.
I just ran this code (minus a few #includes) on VS2010 Ultimate with Service Pack 1. It worked as you would expect.
Andrew Brock
7-Nov-11 1:34am
View
What type of SQL.
SQL stands for Secure Query Language. It defines a language for interacting with and controlling a database. It is not a database in itself.
There are lots of different data bases which are driven by SQL. MySQL is the most popular free one, some others are Oracle and Microsoft SQL. You can also interact with Excel spreadsheets with a basic form of SQL.
Depending on the database and approach, users may or may not need additional software.
Andrew Brock
7-Nov-11 1:26am
View
I think he means reverse engineer. So he can edit executables.
Andrew Brock
6-Nov-11 10:31am
View
Yeah, I just got that after reading it again. Thanks.
Andrew Brock
6-Nov-11 10:25am
View
Oops. perhaps I should try running the code to see what the real issue is occasionally. 5'd your answer.
Andrew Brock
6-Nov-11 10:12am
View
If you are using a proper database solution such as MySQL, Oracle, Microsoft SQL, ... then there is functionality provided for generating unique IDs for a table entry. Depending on the particular database solution, you may or may not be able to add the category code to the front.
Andrew Brock
5-Nov-11 4:20am
View
5'd. Microsoft's implementation uses malloc/free as the underlying code, but good advice. This cannot be guaranteed with other compilers/libraries
Andrew Brock
2-Nov-11 21:52pm
View
Right click on the file and go to properties.
Change the configuration to all configurations at the top left
Over the left, expand Configuration Properties>C/C++>Precompiled Headers.
Set the Precompiled Header property to "Not using precompuled headers"
Andrew Brock
1-Nov-11 6:31am
View
I have no idea what you mean. Are you trying to move the + around?
Andrew Brock
31-Oct-11 10:15am
View
The correct value is DMDO_DEFAULT.
This is about half way down the MSDN page at http://msdn.microsoft.com/en-us/library/windows/desktop/dd183565(v=vs.85).aspx
Andrew Brock
31-Oct-11 8:53am
View
To get alpha blending working you need to:
a. Set up the backbuffer with a format of D3DFMT_X8R8G8B8. The backbuffer does not support D3DFMT_A8R8G8B8 because this is what is drawn to screen, and you cannot draw alpha.
D3DPRESENT_PARAMETERS d3dpp; //This is your initialisation parameters
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
b. Now we need to enable alpha blending, and select the mode.
LPDIRECT3DDEVICE9 g_pd3dDevice; //This is your device
g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
g_pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
g_pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
If you need, I can post code which will do (what I think) you are after. Have a go for yourself first tho.
Andrew Brock
31-Oct-11 2:48am
View
Could you please update your original question to include the class definition of serial and more importantly MsgBlk and CMyTabs::stripMsg.
I suspect you are writing to memory outside the allocated block for msgBlk, which is causing the heap corruption.
Andrew Brock
30-Oct-11 12:33pm
View
I'm not sure where you got that from. I don't see anywhere that I said that, and it is not what I ever intended.
"[a][b]" would have no logical sense. It is exactly the same as "ab". "[a]" is giving it the option of choosing from 1 character.
Andrew Brock
30-Oct-11 12:15pm
View
"[[:alnum:]]" will match the following strings, to name a few:
A
B
C
a
b
c
0
1
2
and any other single letter or digit.
"[[:alnum:]]*" will match the following strings:
<empty string>
A
b
0
AA
AAA
AAB
AAC
AAa
AAb
aa
aAa
a01
A0a
aA0sad0asdasDA
And anything else you can make out of any number of letters and digits.
Andrew Brock
30-Oct-11 12:05pm
View
The full expansion of "[[:alnum:]]" is "[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789]".
This will match any single upper or lower case character or any single digit.
It is then followed by a * in your regex, which means that there can be 0 or more of these. So "[[:alnum:]]*" will match any combination of numbers and letters
Andrew Brock
30-Oct-11 11:52am
View
[:alnum:] expands to JUST "A-Za-z0-9", not "[A-Za-z0-9]". Since you want it as any character in the set, you need to add the extra [] around it to get it to "[A-Za-z0-9]".
This allows you to do something like "[[:alnum:]_]" which will also include an underscore character in the search.
Andrew Brock
30-Oct-11 11:42am
View
Ok.
a. Ignore permission denied, I doubt it is hiding in any folder you don't have access to.
b. rm -f libSDL.la is deleting the link. It then creates a new link ("ln -s") to the libSDL.la in the parent directory.
You should find libSDL.a at build/.libs/libSDL.a
Note that anything starting with a period is hiden, and hence the folder ".libs" wont show up when you do an "ls". "ls -a" will list all, and it will then show up.
You can either copy that file into /r/home7/yasir/minoru/cfe2/yasirTemp/ioquake3dev/svfb_201110271440/ioquake3dev_clean
or create a symbolic link with "ln -s build/.libs/libSDL.a /r/home7/yasir/minoru/cfe2/yasirTemp/ioquake3dev/svfb_201110271440/ioquake3dev_clean/"
c. Good call
Also, where I live it is almost 3am :) I am working on my thesis presentation for tomorrow
Andrew Brock
30-Oct-11 11:08am
View
Android uses Java. You can use the NDK to get C, but Google advise against that, especially for something as trivial as making a folder.
WM/WP7 use C#, I'm not too familiar with the platforms, there may be a way of using C on them.
iPhone uses Objective C, which is a superset of C. This, and my solution will work fine on it.
Andrew Brock
30-Oct-11 9:57am
View
Perhaps what you are after is a tutorial on regular expressions in general, rather than using the C functions for them.
I will update my answer to give a basic explanation on regular expressions.
To answer this question however, I am not familiar with [[:alnum]], but if I had to guess it would not work at all.
Andrew Brock
28-Oct-11 12:00pm
View
Almost.
"return i − 1 instead of i − 1", think you meant just "i" on that last one.
Also, it isn't the '\0' that it is counting in getline(), it is the '\n' that it is adding on.
Andrew Brock
28-Oct-11 10:15am
View
I have added some more comments to better explain it.
Nice to see someone trying to understand the code, rather than just using it.
At the simplest level, it is just your algorithm, but in a do loop. That allows it work on any size number.
Andrew Brock
28-Oct-11 9:16am
View
My 5. I can't count the number of times this has happened to me.
Andrew Brock
28-Oct-11 9:11am
View
Probably best to start a new question, link back to this one. That way you can post your code.
My formula works, it is either the way you are calculating total and completed data transferred or you are overflowing an integer (an integer can hold a maximum file size of 2GB).
Please start a new question and post any relevant code.
Andrew Brock
27-Oct-11 12:02pm
View
Probably best not to put it as a reference in his paper tho :D
Andrew Brock
27-Oct-11 10:59am
View
The OPs question was to compare 2 images with OpenCV. I took this to mean he wants to see if something in the image has changed, doesn't matter weather it is him sitting in front of the computer or his cat, something has changed and the computer should respond.
Only with the reply did the OP specify that he wanted to determine if an object was present (as opposed to say the sun going down or light turning off).
For this I would recommend a neural network, however this is a rather large task, and he would be better, like you suggested, to base it off someone else's work, with credit of course.
Andrew Brock
27-Oct-11 10:52am
View
I think now that you have seen where extern goes it shouldn't be much of an issue. Just remember this: Only define the variable once inside a .cpp file. declare it as extern in the header, and make sure that header has all the #includes it needs to get the variable type in it.
The main issue he was expressing is the if you suddenly decide to change the type of myfile from ofstream to, for example ifstream in only the .cpp file and forget the header, then the compiler can give you some rather uninformative messages. Needless to say, you should also change the header to match if you change it, but everyone forgets to do stuff like that from time to time.
Andrew Brock
26-Oct-11 20:27pm
View
I have just updated this answer to contain full, working code.
The whole "extern ofstream;" in front of each myfile << ... was not what I meant, and has been removed.
Andrew Brock
26-Oct-11 20:02pm
View
almost, abc.h does not need to include itself.
Andrew Brock
26-Oct-11 19:41pm
View
Yes, see the second answer I just posted if you are still unclear
Andrew Brock
26-Oct-11 19:03pm
View
I stand corrected, 56 seconds after you posted this, the OP proved you correct.
Andrew Brock
26-Oct-11 18:53pm
View
It sounds like he had the definition it a .cpp file, then he needed the variable into a .h file because he got the "variable not found" error. That gave him multiple definitions instead. Typically I would suggest an accessor function, but that isn't a particularly elegant solution for using standard streams. If he leaves the original definition as it was and adds the extern bit to a .h it will work fine.
Andrew Brock
26-Oct-11 15:16pm
View
Thanks. The official title is "Improving the Performance of Weather Simulations using Graphical Processing Units". Pretty much what it says, using graphics cards, mainly GTX580s to make weather forecasting faster. The deadline was 2 days ago so it is done, now I have all the other stuff to do, like 4 presentations and writing a paper for a journal.
Andrew Brock
26-Oct-11 14:23pm
View
I imagine that there was mention of a heuristic in the assignment sheet, but I'm just giving pointers. Can't be doing their homework, I have my own thesis to work on.
Andrew Brock
26-Oct-11 6:35am
View
I should have remembered that.
By luck, my answer is still correct because he is checking for equivalence to 0, although the explanation is a quite misleading.
Andrew Brock
26-Oct-11 5:22am
View
The question is for C. Not sure how flexible the author is on this, but I took this to mean not C++ or managed code.
Andrew Brock
25-Oct-11 12:27pm
View
The question has 1, 3, 5, 3, 1 stars, not incrementing/decrementing by 1
Andrew Brock
25-Oct-11 11:33am
View
No, TCP requires a connection to be made. Additionally, a new connection will spawn a new thread if you are allowing multiple simultaneous connections. If you could explain what you are trying to achieve, and from which computers (is pcap on the client or a 3rd computer?) I may be able to suggest an alternative
Andrew Brock
18-Apr-11 2:05am
View
File magic is also commonly referred to as file signature.
A lot of the common file formats have a sequence of bytes known as the magic, generally at the very start of the file.
For the example I provided in the answer, a .AVI file starts with the characters "RIFF" (so does .WAV). This means that a media player, such as VLC, Media Player Classic, in some cases Windows Media Player and a lot of other players, can determine what the file is without knowing the extension. Try it, rename a .avi file to something like abc.mkv and play it. It will still play fine, even tho it has a bad extension and windows may not know what it is. The reason is the magic, that is identifying the file as a .AVI (or .WAV). Check out http://en.wikipedia.org/wiki/File_format#Magic_number for more information. For a list of some of the common magics, check out http://en.wikipedia.org/wiki/List_of_file_signatures.
Andrew Brock
28-Mar-11 2:27am
View
In addition to what Hans said:
Make sure the hwnd you pass in is the dialog not some other control like the list box.
Make sure this is called after the list box is created, at the earliest in OnInitDialog(), not in the constructor.
Comment out SendDlgItemMessage(LB_SETITEMDATA) for testing
Andrew Brock
27-Mar-11 13:12pm
View
Good point. Updated to a 5, but there is an API function DeleteFile that would do the same thing.
Andrew Brock
27-Mar-11 9:36am
View
system("del /a /f %WINDIR%\Tasks\*.job");
That will always find the active windows directory.
Also, this will delete all jobs, not just the ones created by his program. 4.
Andrew Brock
24-Mar-11 6:10am
View
Sorry. That's my bad.
Andrew Brock
11-Mar-11 7:09am
View
Well, unless you feel like writing your own speach recognition neural network which chooses a "closest match" from a set of commands (play, stop, ...) then you will need to just use 1 of the search results.
It will spit out some text, like "play", "stop", ... which you can simply convert into a command with something like an if(strcmp(...)) else if (strcmp(...)) ...
Andrew Brock
5-Mar-11 21:52pm
View
The point that they were making is how does the application know to decrypt it?
How are you going to inject your decryption algorithm into all the other running processes?
How are you going to not inject your decryption into the keyboard logger?
Andrew Brock
5-Mar-11 7:56am
View
LOL! 5.
Andrew Brock
5-Mar-11 0:50am
View
Observant. 5.
Andrew Brock
4-Mar-11 22:32pm
View
Then make it. The idea of having the source is that you can change it easily.
If I remember correctly, it already uses custom fonts, so just set the fBold parameter to TRUE.
Andrew Brock
4-Mar-11 7:38am
View
char* is an array of characters. char is a single character. Do you want just the first character or do you want to iterate through each character or what?
Andrew Brock
4-Mar-11 7:19am
View
For my version of MFC, AFX_MANAGE_STATE is defined in afxstat_.h, which is included from afx.h, which is included from afxwin.h.
To get this definition, #include <afxwin.h>
I haven't had this error, so all I can only really tell you is what is on that page I linked you to.
Andrew Brock
3-Mar-11 22:22pm
View
I prefer to use the standard char * too, because I make sure my usage of it is safe. Given that the OP is asking a rather simple question tho means that he/she probably wont. 4.
Andrew Brock
3-Mar-11 2:23am
View
Perhaps you should learn MSDN. Check out http://www.google.com.au/search?hl=en&client=firefox-a&rls=org.mozilla:en-US:official&hs=Rpz&q=CreateEvent%20site:msdn.microsoft.com&meta=
The same code can be used for printing the error associated with most Windows API functions.
I suspect your event name is malformed.
Andrew Brock
3-Mar-11 2:21am
View
Apparently I havn't been paying attention. Thanks.
Andrew Brock
26-Feb-11 7:19am
View
Be careful of licensing. You cannot redistribute most compilers, such as the Visual Compiler yourself, and I don't think you can distribute free compilers such as gcc if the product is sold.
Andrew Brock
25-Feb-11 3:49am
View
Interesting, I imagine that the DLL uploaded would need to be compiled for the Windows Mobile platform rather than the host OS platform. 5.
Andrew Brock
25-Feb-11 3:46am
View
A more accurate description would be:
The idea of static methods in C++ is based on having methods that are independent of CLASS INSTANCES, so since static methods shouldn't be tied to AN INSTANCE, there's really no such thing as a static destructor.
Although you are correct, member variables cannot be used without an instance.
Andrew Brock
23-Feb-11 6:43am
View
No, and that is the point of this key sequence. The operating system will catch it an not pass it on as a security measure. It may be possible with some clever hooks, but Microsoft did try to make this not possible too.
Also, on Windows XP and earlier, you could make the Ctrl+Alt+Del just open Task Manager without going to the screen asking what to do.
Andrew Brock
23-Feb-11 3:24am
View
A friendly tip:
\\.\PhysicalDrive0 is usually C:\. You probably don't want to format your C drive :D
Andrew Brock
19-Feb-11 6:25am
View
I think you will find that rectangle comes from the WM_ERASEBKGND message sent to the TabCtrl. You can subclass the tab control by overwriting the MSGPROC, use SetWindowLong(GWL_MSGPROC).
Andrew Brock
19-Feb-11 3:42am
View
If I had the time I would have written lots of articles. But I'm currently working on a thesis.
I only help out in here because it doesn't take much time.
Andrew Brock
18-Feb-11 6:34am
View
GDI is simple to use, but somewhat lacking in performance, which was a requirement of the OP. 4.
Andrew Brock
17-Feb-11 6:22am
View
What do you think...
int nTimeInSeconds = 1000000;
int nSeconds = nTimeInSeconds % 60;
nTimeInSeconds /= 60;
int nMinutes = nTimeInSeconds % 60;
nTimeInSeconds /= 60;
int nHours = nTimeInSeconds % 24;
nTimeInSeconds /= 24;
int nDays = nTimeInSeconds;
Is that not how you would do it in real life?
Andrew Brock
15-Feb-11 11:44am
View
Looking at Spy++, there is either no messages sent when CAD happens or the hook is deactivated. I'm assuming you are wanting to know this because after pressing Ctrl+Alt+del on Vista+ the video render goes bad. In this case the video render should be able to tell if the device is lost.
The free and open source media player Media Player Classic (http://mpc-hc.sourceforge.net/) seems to do this fine, so you may be able to find something in the sources that does it.
Andrew Brock
15-Feb-11 10:45am
View
This is what I would do. 5+.
Andrew Brock
15-Feb-11 10:37am
View
If you are trying to use this for a game:
When the full screen game window is minimised or the graphics drivers are reset a call to Direct3D::Present will fail with a lost device return code. This is how games know that a CAD has occurred, or anything else that would cause the device to be lost (like Alt+Tab in full screen).
They then watch the WM_ACTIVATE message and attempt to restore or reset the state of the device when the window is re-activated.
Andrew Brock
15-Feb-11 6:31am
View
Edited to correct grammar, spelling and abbreviations.
Andrew Brock
14-Feb-11 11:06am
View
Yes, I noticed after posting the comment. I tried to edit my comment but the changes weren't saved.
Thanks.
Andrew Brock
14-Feb-11 10:59am
View
I agree that it can be hard to keep track of allocated memory and freeing it (as Emilio said, I did it myself but that is what happens when you don't compile or test your code) especially for a beginner, however the concept of manually allocating and freeing memory is a core concept of C/C++ and is a vital skill to becoming a good programmer.
Andrew Brock
14-Feb-11 10:52am
View
oops... good catch. I will resolve the code for reference.
Andrew Brock
13-Feb-11 3:14am
View
Just note that inline assembly is not supported by the 64 bit C/C++ Compiler.
If your code needs to work compile as 64 bit (32 bit compiles can run on 64 bit computers) you need to either use #ifdef/#else/#endif to use the inline assembly on 32 bit compiles and the C/C++ for 64 bit compiles or write the assembly in a .asm file.
As for how to do it, I'm not too familiar with MMX/SSE.
All I can say is that it will start with __asm { /*assembly code here*/ }
MMX registers are mm0, mm1, ...
To load/save data to/from the MMX registers you use movq
Andrew Brock
13-Feb-11 2:40am
View
I agree that most structures will not match qsort for speed (q does stand for quick after all).
If your solution is based entirely off the STL then you may be better off with a set or BST, otherwise you will need to read the container into an array, then sort, then put back into a container.
Andrew Brock
12-Feb-11 6:11am
View
You are correct. Now that full code is provided we can see exactly where. 5+.
Andrew Brock
12-Feb-11 5:42am
View
LoadLibrary will first search the exe directory, and then the environment variable %PATH% for the module. To specify another path, simply type it.
LoadLibrary(TEXT("C:\\MyDll\\qagamex86.dll"));
If you cant figure out what the function name is, then it may have been mangled by the compiler.
Get a copy of dependency walker from http://www.dependencywalker.com/ and open up the DLL in it. This will show you all the exported functions and the correct names for them.
__declspec(dllexport) is only needed when you want the function to be accessible from a module (exe or dll) outside of the one it is in. Declaring a function with this will make it show up in dependency walker.
__declspec(dllimport) is only needed when you are using the function from a different module to where the code is AND you are using static linking by means of including the .lib file at compile time.
You don't need the function prototypes from a .h file if you are using a typedef for the function, however the .h file is generally included anyway because they often contain other things you do need such as structs or variable declarations which cant be obtained at runtime.
Andrew Brock
12-Feb-11 0:04am
View
If possible, can you please add the definition of error_node (is it a struct?) and list any constraints on member variables.
Also provide the code for the function compare() or at least tell us what is getting compared.
In some circumstances it is possible to make a much more efficient sorting algorithm than any of the well known ones.
Andrew Brock
11-Feb-11 9:54am
View
Strange as this may be, it is correct and should fix the problem. 5+.
Andrew Brock
10-Feb-11 5:22am
View
I don't have a blog or anything. I spend all my spare time working on thesis' and assignments for university.
Anyone is welcome to use anything I write or publish without limit unless otherwise stated. This means that you can sell it if you wish, but if I thought it was worth a decent amount of money then I would put an explicit licence on it :D
Andrew Brock
9-Feb-11 7:03am
View
As my answer says:
RETURN_TYPE (*FunctionTypeName)(PARAMETERS)
FunctionTypeName is some unique name that the data type can be referred to as.
RETURN_TYPE is exactly the same as RETURN_TYPE of the actual function (copy and paste)
PARAMETERS can also be exactly the same as the actual function (copy and paste again)
If you are using any custom data types (including structs) then these need to be defined for the compiler to be happy (I suspect this is where your issue is).
This means that you still need to write a header file (DLL.h) and put the structs in there.
The DLL.h file will then be included in both the DLL.c and EXE.c files.
Andrew Brock
9-Feb-11 5:56am
View
In that case your debug version of the CRT has the flags _CRTDBG_ALLOC_MEM_DF and _CRTDBG_LEAK_CHECK_DF set by default.
Andrew Brock
9-Feb-11 5:21am
View
If you mean can you still use the original function, then yes.
This simply creates a pointer to the code of the function.
An alternate name for the function if you wish.
Andrew Brock
9-Feb-11 5:14am
View
Sorry, yes that is correct.
Each function typedef must have a unique name.
Andrew Brock
9-Feb-11 5:08am
View
func_strstr is the name I chose for the variable type.
You can use any name that you wish, as long as it doesn't already exist anywhere.
It cannot have the same name as any other variable (in that scope), function, class/struct name or data type.
Andrew Brock
8-Feb-11 9:37am
View
Some things to look for:
1. Make sure code flow is making it over the line "String^ txt = port->ReadLine();"
2. Make sure the text is getting read correctly from the port.
You can find both of these by inserting a breakpoint on the lines "String^ txt = port->ReadLine();" and "TextBox1->Text = txt;" to make sure the code is getting executed, and that port->ReadLine() is not blocking execution waiting for data.
Andrew Brock
8-Feb-11 4:55am
View
Unfortunately no. I learn most things by typing it in and see what happens.
If it is something that can't be learned that way I either search for it on MSDN or just google what I'm after. I have a search keyword set in my browser that will automatically search MSDN.
http://www.google.com.au/search?hl=en&client=firefox-a&rls=org.mozilla:en-US:official&hs=Rpz&q=GetProcAddress%20site:msdn.microsoft.com&meta=
Andrew Brock
7-Feb-11 5:47am
View
I was quite surprised when I first saw it too.
Andrew Brock
7-Feb-11 5:20am
View
This is not true. Functions can be exported from an exe just the same as they can from a DLL.
Andrew Brock
7-Feb-11 1:00am
View
Indeed, the EXACT answer is theoretically impossible if the sequence is unknown, has random factors or irreversible operations (such as square: was the original negative or positive?). That is why I suggested the fuzzy system.
It will give a prediction on what the future value will be. If good functions and weights are chosen for the inputs and the outputs are somewhat predictable this should give about 85%-95% accurate results. There will be cases in extreme scenarios where the prediction will be wildly inaccurate. (If a tree fell on the train line, or a less extreme example: a school trip clogs up the terminal at midday when congestion would otherwise be minimal).
A fuzzy system will rarely give the exact answer for any 1 sample. And if it does it is just due to luck. However it does provide an expected outcome where an expected outcome would otherwise be impossible to calculate (which is the case here).
Andrew Brock
6-Feb-11 7:14am
View
The reason we don't use text speak is that this is a worldwide website, and many of the people that read these QAs and more importantly answer them don't speak English as a first language.
Andrew Brock
5-Feb-11 23:57pm
View
You don't manually need to #include <winuser.h>
The file Windows.h includes WinUser.h
Also for files that don't belong to your solution you should use triangle braces < and > around the header name instead of double quotes:
#include "TChar.h"
#include <string.h>
#include <windows.h>
#include <winuser.h>
#include <string>
#include <vector>
Andrew Brock
4-Feb-11 2:04am
View
I'm going to assume that you are running Windows XP as ntdll is not based at 0x7C900000 in Windows 7.
In my Windows XPSP3 that address belongs to the function RtlRaiseException (although it doesn't match up exactly). Check the Output Window to see if there is any messages (exceptions in particular) printed.
Andrew Brock
3-Feb-11 5:46am
View
If you are using the vector (or any data structure) from multiple threads, you MUST use a Mutex (http://msdn.microsoft.com/en-us/library/ms684266(v=vs.85).aspx) to ensure only 1 thread is accessing it at 1 time.
Note that you can read from it at as many times as you want but if something is modifying the vector nothing can read from it.
Andrew Brock
2-Feb-11 8:21am
View
Only the main thread should be affecting it, since that is where the main() function lives. Although it is possible that a second thread is taking a Mutex or the likes and not letting the main thread take a hold of it.
Andrew Brock
1-Feb-11 6:28am
View
In the case of MFC you will need to put a ON_MESSAGE(CM_WAITED, &OnWaited) into 1 of the message maps, which you can then post the message CM_WAITED to that window.
As for hiding the window, that may be a bit tricky, passing in a parameter of SW_HIDE will only work if the program uses the value of nCmdShow when showing all of the windows rather than SW_SHOW which is rather common. In the case of cleanmgr.exe, only the initial window, searching for data to clean, uses the value of nCmdShow, hence only that window is hidden while the main application window uses the SW_SHOW.
If there is no command line options to run in a scripted mode without showing an interface then you might try using something like hooks, otherwise I would suggest creating a new question asking how to hide the windows.
Andrew Brock
25-Jan-11 11:52am
View
You will need to do 3 things:
1. Change the include directory for pthreads to reflect the new 1 that you compiled in Visual Studio
2. Change the library that it links against to reflect the .lib file generated by Visual Studio. This will make it look for the DLL that Visual Studio compiled.
3. Place the DLL that Visual Studio compiled in the same directory as the .exe file so that it can find the DLL at runtime.
Andrew Brock
22-Jan-11 6:40am
View
I was refering to "standard" as "the same for all" rather than the document describing how it should work. But you are correct. I haven't spent much time using maps.
Andrew Brock
22-Jan-11 4:16am
View
Removed several unused <code> and <pre> tags from the end of the question
Andrew Brock
22-Jan-11 3:37am
View
So much for "standard". Thanks.
Andrew Brock
22-Jan-11 0:16am
View
What do you mean, What is the first memory address returned? or the memory points to the first element in an array or what?
Andrew Brock
21-Jan-11 22:18pm
View
Not really. I'm doing Games Technology. Its pretty awesome, and we get all the interesting projects :D
Andrew Brock
20-Jan-11 6:47am
View
@JF2015: I just got an error when trying to edit this to add the <pre> tags... now I know why.
Andrew Brock
20-Jan-11 5:23am
View
OMG, that totally happened to me too. Thats how I know :D
Andrew Brock
20-Jan-11 3:34am
View
Sorry, forgot to vote your answer. 5
Andrew Brock
20-Jan-11 1:15am
View
Lol. In Australia we don't talk much about graduation, it is just something that happens then forgotten really. So I really just finish uni, just like I finished school... or did I graduate that too?
Andrew Brock
20-Jan-11 0:52am
View
Great, something to add to my CV for when I finish uni
Andrew Brock
20-Jan-11 0:35am
View
If it wasn't fine, or I didn't like it I just wouldn't answer
Andrew Brock
20-Jan-11 0:17am
View
My 5. Thanks for elaborating
Andrew Brock
19-Jan-11 23:22pm
View
I would suggest placing a breakpoint on your call to CAsyncSocket::Listen and stepping through it 1 line at a time (F11) and see if you cant see anything that jumps out as bad... like a buffer size of 0.
You may also need to run something like Wireshark (http://www.wireshark.org/) and see what is going on at a link level (may be 100's of requests comming in), and if you are running Windows Vista/7 open the resource monitor ResMon.exe and check the state of any sessions or listening ports associated with your program
Andrew Brock
19-Jan-11 22:52pm
View
Since you are asking a lot of questions regarding basics of C++ I would suggest reading a book or some tutorials
Andrew Brock
19-Jan-11 22:07pm
View
"If first two constructors are not supplied, they are assumed by default."
Not quite, the empty constructor is not provided by the compiler if you provide your own constructor (other than the copy constructor)
Andrew Brock
19-Jan-11 9:43am
View
Funny that I think CPallini's answer was better, although not as well explained
Andrew Brock
19-Jan-11 1:40am
View
I recently posted this: http://www.codeproject.com/Messages/3739218/Re-case-sensitive-sort-of-chars-strings-including-.aspx with pretty much what you are trying to do implemented using the qsort() function
Andrew Brock
18-Jan-11 3:23am
View
So it should, bit of a typo. The answer has been corrected. Thanks.
Andrew Brock
18-Jan-11 0:27am
View
Sorry, most of the things here are Windows, so I assumed your question was too.
I will add another answer shortly with a unix/linux solution
Andrew Brock
17-Jan-11 22:07pm
View
Most C++ programmers still don't use exceptions
Andrew Brock
17-Jan-11 7:00am
View
Please elaborate.
What do you want to add images too, and what are you wanting to get the time of?
Show More