QueryCancelAutoPlay does not work in Release Mode

Posted on 2010-11-23
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... ...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).
Question by:HooKooDooKu
  • 2
  • 2
  • 2
LVL 86

Expert Comment

ID: 34202304
What is your actual code?

Accepted Solution

Orcbighter earned 500 total points
ID: 34204695
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.
LVL 16

Assisted Solution

HooKooDooKu earned 0 total points
ID: 34224082
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.
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.


Expert Comment

ID: 34225102
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?

LVL 86

Expert Comment

ID: 34225829
Sorry if I might be repeating myself: What is your actual code?
LVL 16

Author Closing Comment

ID: 34272741
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.

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
When you try to share a printer , you may receive one of the following error messages. Error message when you use the Add Printer Wizard to share a printer: Windows could not share your printer. Operation could not be completed (Error 0x000006…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…

789 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