Solved

QueryCancelAutoPlay does not work in Release Mode

Posted on 2010-11-23
6
915 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
ID: 34202304
What is your actual code?
0
 
LVL 9

Accepted Solution

by:
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.
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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
By default the complete memory dump option is disabled in windows . If we want to enable the complete memory dump for a diagnostic purpose, we have a solution for it. here we are using the registry method to enable this.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

948 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

23 Experts available now in Live!

Get 1:1 Help Now