Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

QueryCancelAutoPlay does not work in Release Mode

Posted on 2010-11-23
6
Medium Priority
?
936 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 34202304
What is your actual code?
0
 
LVL 9

Accepted Solution

by:
Orcbighter earned 2000 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.
0
 
LVL 16

Assisted Solution

by:HooKooDooKu
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.
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
LVL 9

Expert Comment

by:Orcbighter
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?


0
 
LVL 86

Expert Comment

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

Author Closing Comment

by:HooKooDooKu
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.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
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 learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

670 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