Solved

QueryCancelAutoPlay does not work in Release Mode

Posted on 2010-11-23
6
910 Views
Last Modified: 2012-05-10
I have an Dialog-based MFC application that reads data from CDs.  During program execution, the user can change CDs to research data from a different CD.

To avoid the "AutoRun" window when CDs are swapped out, I'm following the instructions for responding to the QueryCancelAutoPlay message as described here... http://msdn.microsoft.com/en-us/library/cc144204(VS.85).aspx ...except that I'm setting up a message handler with ON_REGISTERED_MESSAGE.

When I compile the application in Debug mode, the AutoPlay window is cancelled just like expected.  But if I change my project to Release mode, the AutoPlay window still displays.  I've tested this on at least two machines (both running Windows 7 - 64 bit).  I've inserted an AfxMessageBox to the message handler to prove the problem seems to be in my top-level window getting the message (NOT a problem with the response to the message).

When I created this MFC Dialog Project, the only options I changed was to use MFC in a Static Library and Use Multi-Byte Character Set (as well as the typical changes for Include Directories, Additional Linker Dependencies, and Additional Library Directories).
0
Comment
Question by:HooKooDooKu
  • 2
  • 2
  • 2
6 Comments
 
LVL 86

Expert Comment

by:jkr
Comment Utility
What is your actual code?
0
 
LVL 9

Accepted Solution

by:
Orcbighter earned 500 total points
Comment Utility
As a general hint, if something works in Debug mode but not in Release mode, that tends to hint at some values not being initialised properly (a default action of the debugger), either to zero, or null, or to a valid value. A close look at your code with this mindset might reveal your problem to you.
0
 
LVL 16

Assisted Solution

by:HooKooDooKu
HooKooDooKu earned 0 total points
Comment Utility
So far have not been able to solve the problem.

I tried starting over with a "clean" project and everything worked like it should.  Then I added in all the files from the existing project and the problem resurfaced.  Can't tell yet where the problem would be as it's difficult to only add SOME of the files since it all ties together.

So barring any other suggestions, the only thing I can think to do it to slowly replace the functions in each file with dummy code so that eventually I have the same files but it all an empty shell.  Since I've ruled out a problem with the project properties, It's got to be one of the dialog files that does something with the message loop.
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 9

Expert Comment

by:Orcbighter
Comment Utility
I have had similar problems in my day.
Here is a couple of suggestions. They can be tedious, but since all other avenues have been exhausted....

(1) Step through each section of the properties of the solution file line by line, at each one flick between the Debug and Release configurations and look for any differences that don't pertain to debugging. If there is a flag that was set in Debug, or a lib file included in debug, or some other setting that was forgotten to be included in the Release version, this method will show it up. Any discrepancy here would be an indicator of why things don't work in Release mode.

(2) Ensure that all compiler and link warnings are turned on to ensure that there is no conflict between any of the libraries in your project and any included projects or dlls.

(3) The link in your question states that, for things to work, your window must have the focus. Have you proven, to yourself, that at the time the AutoRun message is generated, the part of your application containing the message handler does, in fact, have the focus. Remember, that the Debugger is an event trapper and may be automatically granting you focus, whcih will not happen in Release mode. If your code is in a dialog, is that dialog modal?


0
 
LVL 86

Expert Comment

by:jkr
Comment Utility
Sorry if I might be repeating myself: What is your actual code?
0
 
LVL 16

Author Closing Comment

by:HooKooDooKu
Comment Utility
Using my own suggestion of deleting code until the problem went away has found the problem.

I had a fixed length array where a "Clear the Array" function would nullify one extra element base the end of the array.

Now how in the world nullifying a single bytes would cause such a strange ill effect, and only cause it in Release and NOT Debug I still don't understand.

But I'm awarding the points for the suggestion about looking at how things are initialized.  I'm giving a grade of 'C' just because the actual problem was sort of the opposite what was being suggested, but I did want to point out that the suggestion was sort of related to what the problem was.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

So many times I have seen the words written in a question "if only I could show you" or " I know how hard it is for you since you can't see it" in any zone. That has inspired me to write about this tool in windows 7 called "Problem Steps Recorder…
The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum editing capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now