 |
|
 |
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
|
 |
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode HTML tags when pasting" checkbox before pasting anything inside the PRE block, and make sure "Ignore HTML tags in this message" check box is unchecked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question in one forum from another, unrelated forum (such as the lounge). It will be deleted.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
|
 |
Hi, I have a Window app from which I am doing communication to a DOS app via named pipes My method of doing this is to signal a event after I have queued the messages to the DOS app The method from which I am signaling the event is inoked via SendWindow and has and thus has a prototype LRESULT (WPARAM, LPARAM) The problem is as soon as I SIGNAL the event control is transfered When control is returned to the method which signaled the event it executes the next statement which causes an access violation listed below is the code in question <pre lang='cpp'> LRESULT CprogDebug::receive_tcpip(WPARAM mywparam,LPARAM mylparam) . . . . . myeventptr->send_window = this; myeventptr->SetEvent(); // queue message return TRUE; // <==== access violation </pre> Thanks in Advance
|
|
|
|
 |
|
 |
I have this program that I wrote in vb, and I want to rewrite it in c++. I would like to retain the click once deployment feature, but I don't know which ones support click once.
|
|
|
|
 |
|
 |
None that I know, but rewriting it in C++ will beat it in complexity by a mile.
If you are interested in one-click deployment solutions, opt for a rewrite in C# instead
P.S. There is, of course, such thing as Install-Shield, something I would not recommend anyone, after using it for couple years, and then moved to NSIS, no looking back.
|
|
|
|
 |
|
 |
Hi everybody,
As you could read in my other question. I want to get rid of the CRL both external (/MT) or internal (/MD).
I am almost done and I eventually also want to remove the input of the msvcrt.lib. As soon as I do that I get an error on having _ftol2 etc not defined.
So I looked up my program in IDA and I noticed that they automatically generate _ftol2 and use it to convert from float to long.
Anybody knows how to get rid of these automatically generated functions.
Regards,
SystemFiles
|
|
|
|
 |
|
|
 |
|
 |
yeah that will probably work. I will give it a shot.
EDIT: That worked flawless thanks!
modified yesterday.
|
|
|
|
 |
|
 |
Hi everybody,
I want to get rid of all the imports from the CLR. So I decided to make some functions on my own for example cos() sin() tan() asin() acos().
I already have cos and sin and tan done:
FLOAT Sin( FLOAT A )
{
_asm FLD A;
_asm FSIN;
}
FLOAT Cos( FLOAT A )
{
_asm FLD A;
_asm FCOS;
}
FLOAT Tan( FLOAT A )
{
_asm FLD A;
_asm FPTAN;
}
As you can see I am using inline floating point assembly. But then I thought I could probably use FACOS or FASIN, but those instructions don't exist.
Anybody know how I could constructe asin() and acos(), without using the CLR ofcourse.
Regards,
SystemFiles
|
|
|
|
 |
|
 |
when sine or cosine are known, so is the other (remember sin^2 + cos^2 = 1), hence also the tangent. Therefore use FPATAN.
|
|
|
|
 |
|
 |
takes a while before I understand what you mean hehe math actually isn't my best point of programming.
I will get to this later!
|
|
|
|
 |
|
 |
Hello people,
I was wondering of any good driver development/tutorial websites, books and source code I could "scan," (including source code of your own) cause I'm completely new to this and heard that driver are extremely powerful (especially in kernel-mode) and can do some neat things (firewalls)
Simple Thanks and Regards,
Brandon T. H.
Been programming in Visual Basic for 4 years this point forward, and is very good at it (I can even create programs completely on code, without dragging those items from the toolbox). Programming C++ for 1 year so far and the same with C#.
Many of life's failures are people who did not realize how close they were to success when they gave up. - Thomas Edison
|
|
|
|
 |
|
 |
Brandon T. H. wrote: I'm completely new to this and heard that driver are extremely powerful (especially in kernel-mode) and can do some neat things (firewalls)
I think that's an over simplification, but if you are serious then start here[^] and be prepared for a lot of hard work.
Programming is work, it isn't finger painting. Luc Pattyn
|
|
|
|
 |
|
 |
thank you, very appreciated
Simple Thanks and Regards,
Brandon T. H.
Been programming in Visual Basic for 4 years this point forward, and is very good at it (I can even create programs completely on code, without dragging those items from the toolbox). Programming C++ for 1 year so far and the same with C#.
Many of life's failures are people who did not realize how close they were to success when they gave up. - Thomas Edison
|
|
|
|
 |
|
 |
You may also find that any driver specific questions will have a better chance of being seen by the specialists in this forum[^].
Programming is work, it isn't finger painting. Luc Pattyn
|
|
|
|
 |
|
 |
OSR[^] - These guys are the experts.
Check out their NT Insider articles.
|
|
|
|
 |
|
 |
as superman says, OSR, they do a free mag every two months, its very very good. Their website, osronline, is a must.
http://dumpanalysis.org/ is usefull for analysing dumps, something you are going to be doing a lot of.
Ndis.com is good for network stuff, like firewalls.
Most importantly you want to buy Walter Oneys book, programming the wdm, it is essential.
==============================
Nothing to say.
|
|
|
|
 |
|
 |
Erudite_Eric wrote: you want to buy Walter Oneys book
Bunch of thanks, downloaded it
Erudite_Eric wrote: OSR, they do a free mag every two months, its very very good.
Already signed up
Erudite_Eric wrote: http://dumpanalysis.org/
I'll learn that aswell.
Erudite_Eric wrote: Ndis.com is good for network stuff, like firewalls.
Thank you, this could be very helpful in the future (including everything).
Do you suggest me working for a security company like Faronics (ever heard of Deep Freeze)?
Simple Thanks and Regards,
Brandon T. H.
Been programming in Visual Basic for 4 years this point forward, and is very good at it (I can even create programs completely on code, without dragging those items from the toolbox). Programming C++ for 1 year so far and the same with C#.
Many of life's failures are people who did not realize how close they were to success when they gave up. - Thomas Edison
|
|
|
|
 |
|
 |
Yes, it will give you a lot of experience. I have worked on similar products, and file system drivers, such as those used by Faronics to control applicaiton execution and so on are some of the most complex to write.
==============================
Nothing to say.
|
|
|
|
 |
|
 |
I am currently writing a game in C++ using OpenGL and I wonder which is the best way to deal with errors, once they occur (especially in games).
Note: I am currently using possibility 2, but I'm not really happy with it.
1. Exceptions - At first glance they seem to be the perfect for all kinds of errors, but I found out that exceptions can produce heck of a lot of overhead and extra time cost and IMO they're making the code ugly.
2. Return values - It's said that checking success using return values is deprecated since C++'s built-in exception handling. I can't share that opinion, but retrieving a return value and checking it doesn't seem to be an 'elegant' way of doing this and isn't beautiful as well (due to thousands of if and/or switch statements.
3. Return value + global error indicator - This one's really deprecated, even though I somehow liked the errno thingy in C
So, what do you use/what would you use and what would you recommend for my needs?
Thanks in advance.
PS: Do I have some kind of natural aversion to exceptions or are they really not the greatest invention since sliced bread?
|
|
|
|
 |
|
 |
I think in error handling, performance should not be of concern. So, the "I'm writing a game, everything must be fast!" argument doesn't work here. Errors should always be the exception!
Exceptions really help you to write smaller code. When using return values, you have to check them every time. If you forget to do so, you might miss an error. So they are really prone to bugs!
Exceptions on the other hand can't be simply ignored, and I think that's good.
|
|
|
|
 |
|
 |
forkbomber wrote: ...but I found out that exceptions can produce heck of a lot of overhead and extra time cost...
See here.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
 |
|
 |
Use exceptions for errors you can't recover from e.g:
- Wrong OpenGL version, throw an exception
- No memory - runtime throws an exception for you
- Can't find a critical game resource, a fall back texture, shader or something else that really must be there
- Some muppet's deleted a delay loaded DLL
- Steam doesn't initialise and you're using it for copy protection
- You can't open any file to save the game - throw an exception
Use return values for things you can recover from, e.g:
- Network connection flakey - you don't want your game to crash 'cause your cheap hosting server in Borneo is offline due to Orang-utan attack
- Can't find a game resource that you have a fallback for
- Steam can't share a file, back off and try again
- You can't open a save game file, back off and try again with a different name
If you're code looks ugly you're not using exceptions for critical errors and you've got exception handlers all over the place.
Ideally for yummy, perfect code you should only have exception handlers:
- At the top level of your code - around main, WinMain or whatever for your platform
- Around thread entry/exit functions
- Around window procedures/GUI callbacks
So basically:
- Exceptions are for critical errors
- Exception handlers only appear when your code is about to disapear UP the call stack into the OS, otherwise madness and the end of western civilisation will result.
Exceptions being really expensive is a myth. See one of the previous posts for details, or hey, measure it yourself.
|
|
|
|
 |
|
 |
Hey there and thanks to everybody for clearing things up.
I'm going to use exceptions now.
|
|
|
|
 |
|
 |
I have a Delphi application which Creates a shared memory uses CreateFileMapping, OpenFileMapping, MapViewOfFile functions.
Now I wanted to share the same memory for my MFC application. I used the OpenFileMapping, MapViewOfFile functions.
I created a structure exactly same in size as the Delphi application and mapped the structure object.
sample code:
HANDLE hMapObject2;
hMapObject2 = OpenFileMapping( FILE_MAP_ALL_ACCESS, FALSE, "PP101U3_SHARED");
if( !hMapObject2 )
{
AfxMessageBox("Failed to open Simpack DataBase");
return( 0 );
}
Simpack = ( struct SIMPACKDB *) MapViewOfFile( hMapObject2, FILE_MAP_ALL_ACCESS, 0, 0, 0 );
if( !Simpack )
{
AfxMessageBox("Failed to create Simpack File Map View");
return(0);
}
Esim->SPV1 = Simpack->SP_Z;I am able to read the values exactly correct for all the member variables in the structure.
But when I try to write value in the shared memory, its not changing. It shows the previous value immediately.
The value of Simpack->SP_Z[15] is 0.5010 as read
from the shared memory which is set by the Delphi application.
When I set or write the value of the same variable to the shared memory using the code:
Simpack->SP_Z[15] = 0.6123;it shows the previous value 0.5010. When I change the same variables value in the Delphi application it changes and shows the changed value here in the MFC application.
Please help me how to write the values in the shared memory. Is there anything wrong in the code?
|
|
|
|
 |