Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 941
  • Last Modified:

QueryCancelAutoPlay does not work in Release Mode

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
HooKooDooKu
Asked:
HooKooDooKu
  • 2
  • 2
  • 2
2 Solutions
 
jkrCommented:
What is your actual code?
0
 
OrcbighterCommented:
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
 
HooKooDooKuAuthor Commented:
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
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
OrcbighterCommented:
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
 
jkrCommented:
Sorry if I might be repeating myself: What is your actual code?
0
 
HooKooDooKuAuthor Commented:
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

  • 2
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now