Why am I getting a DDE error when opening a file in Explorer that associated with our application? - visual-c++

Our legacy MDI desktop application uses the /dde switch in the association. When opening a file associated with it, and the application has not yet started up, Explorer pops up the following error:
There was a problem sending the command to the program.
The registry looks something like this:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\App.Document]
#="App File"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\App.Document\DefaultIcon]
#="d:\\Program Files (x86)\\MyApp\\version\\app.exe,1"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\App.Document\shell]
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\App.Document\shell\open]
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\App.Document\shell\open\command]
#="\"C:\\Program Files\\App\\app.exe\" /dde"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\App.Document\shell\open\ddeexec]
#="[open(\"%1\")]"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\App.Document\shell\print]
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\App.Document\shell\print\command]
#="C:\\Program Files\\App\\app.exe /dde"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\App.Document\shell\print\ddeexec]
#="[print(\"%1\")]"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\App.Document\shell\printto]
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\App.Document\shell\printto\command]
#="C:\\Program Files\\App\\app.exe /dde"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\App.Document\shell\printto\ddeexec]
#="[printto(\"%1\",\"%2\",\"%3\",\"%4\")]"
Just to be clear, I just took these entries from the registry. I'm not well versed in what they do, but I can hazard a guess that they link the verbs to actions by way of the DDE interface.
Note that if the application has already started up, the document opens up fine in that instance. This is only an issue if the application hasn't started up and must execute a new instance of the application.
So, what is happening is that the associated file is opened through Explorer by double clicking on it, and the associated application is executed. Explorer would then pop up that message and our application would do nothing. Double clicking on the file a second time would then open the document.
We've had this issue previously, but we just decided to ignore it for a few years as no one really knew what it was and we had other priorities at the time. Our workaround was to tell the user to change the /dde to "%1". Yeah, lame, but it worked well enough. One issue with doing that though, was that it would execute a new instance of the application, regardless if the application was already running or not.
Anyways, this issue is now starting to become an actual problem and needs to be fixed. One of our developers is saying that the DDE system is antiquated and we should try writing a COM component that will redirect to our application like Visual Studio does as debugging this issue could take a while. I've not verified that yet, nor researched how much effort that would be. However, either may be resource intensive, either on the debugging or the research side, so I'm trying to do some preliminary research to see what I can dig up and determine which is the better approach.
Stepping in the code, I was able to determine that it gets to a ::SetWindowPlacement() call and stepping over that will cause the error message box to pop up (if Explorer hasn't timed out first). As it is a WINAPI, I cannot step into that function to see what it is doing.
The application is written mostly in VC/VC++ using MFC/API and other libraries.
So my question is, does anyone know why this is happening and how it can be fixed?
Edit
Some additional information:
I was able to intercept all of the SendMessage()/PostMessage()/DispatchMessage() function calls non-destructively, which will log all of the messages. This was achieved by using MS Detours 3.0.
What I am seeing is that there are 4 SendMessage calls with a WM_COPYDATA message which appears to be coming out of shell32.dll. However, it doesn't appear to be the messages that are at fault though.
Putting a __debugbreak() when it detects the WM_COPYDATA message results in no error until a few steps beyond. How far depends on if I step or if I put a breakpoint and run the code to somewhere beyond where I thought I was getting the error. Using DebugBreak() seems to slow down the debugger to the point where I can't step without the error showing up.
What I can't understand is that there doesn't appear to be any rhyme or reason as to what is triggering the error message to pop up. I doesn't appear to be a timeout as the timeout appears to be long until I start stepping in the code, and sometimes no messages are being Sent/Posted by the code. So there's no WM_DDE_ACK (or any message for that matter) being sent back to the Explorer window that has initiated this. This is very frustrating.
To further complicate things, if I use the intrinsic __debugbreak() call and I have a breakpoint somewhere else in the code, it sometimes can stop at that breakpoint rather than stopping at the __debugbreak(). And sometimes, when I run the code immediately when I get control of the debugger, it will sometimes result in a second break, as if it hit another __debugbreak(). What's that all about? Inconsistent debugging is certainly making this issue even harder to track down. >:(

This DDE stuff is still the in use for MDI interfaces. So if one EXE opens different files.
If you can launch you application multiple times and this is OK, for the customer, switching the entries in the registry to the normal place holders from the SDI is OK too.
Usually this message is shown from the explorer, if the EXE doesn't get ready in a specific time to accept the DDE commands.
So the main question for you is: What is changed or so slow in the application that the DDE messages are not retrieved.
On case would be if it takes a real long time until the message loop starts. A running message loop for the main window is required for DDE support.
SetWindowPos istself will not be the problem, but it might cause hundreds of messages (WM_SIZE, ...) to be fired to your application, and every handler in your application here might be the problem.
Just place a little timer inside the application in front of the SetWindowPos and check how long it takes to return...
Check how long the app takes, until InitInstance is exited with TRUE. After InitInstance exits CWinApp::Run starts and the message loop starts.

I've run into the same problem.
My solution was to add the ../ddeexec/* section in the registry on application startup and then remove them on application exit.
Not a very nice solution but it is easy to do, and it works.

Related

Windows 10 Event Viewer ID description problem

I've looked at so many articles in the past year without finding an answer, I'm starting to go crazy...
I do a lot of application support and use the Event Viewer on a regular basis. On any machine but mine, when I look at an event with Event ID 0, the "data" part of that entry is shown in the General tab of the viewer. This is the default behavior that I like. On my laptop, however, for about a year now, Event ID 0 shows as "The operation completed successfully." I no longer see the "data" part of the event in the General section of the window.
Example of the annoying message
The only thing I can think of, is that I added a custom description (or definition) for Event ID 0. But frankly, I don't know how I did it, if that is the case. I want to go back to seeing the "data" in there, rather than this useless message.
Does anyone know how to fix this?
While not a "fix" to the problem, I have what may be a workaround for you.
First, I can confirm that I have experienced it also--and it's been on MORE than one computer. But it has been limited to only some apps ("sources", in event viewer parlance). So I am assuming it's THEIR doing rather than ours. Your situation may be different.
But second, and until you may find a better solution, I will note also that there may well BE a useful message for you to see. If you click on the Details tab above that message, the "friendly view" of the details will readily show what the "real" message is that underlies that log entry.
See this screenshot showing a Postgres startup message that was hidden under such an "operation completed successfully" log entry.
I have seen it and other apps/sources work this way for such startup status messages, failures, errors, and more.
Like you, I lament that we should have to know to do that. It feels to me like the folks creating the code that create the event log entry are making some choice that leads to this behavior. At least now I know that I can SEE the info they are trying to share, albeit via what seems a poor choice.

Blue Prism: Object not found when ran using Control Center, but runs without issue through Process Studio

During my process there is a drop-down html element that I have spied and set correctly. I run through the Object and Process studio without any issues. Once the same process is ran through the Control Room the element throws and error that it cannot be found.
I have tried multiple different configurations without any luck and the element is still found without issue when ran manually. I even checked by signing into the VM having it error and on the second retry had the VM up; at this stage the element was found without issue. It seems to only be when the bot is running and the screen is not up. No other elements give this issue and the next step is the same dropdown, but for a stop time not start.
Any help would be appreciated!
I have added pics of the STARTSPIED - START and ENDSPIED - END spied configs,the Navigation Stage, and the process correctly running in the Object Studio OB Studio correct.
Thank you!
For the person who down-voted this item...Configs here are my two days of config changes and research that I tried on my own before asking for help. This is my 5th automation that I have put into deployment without help, so thank you for down-voting someone trying to get help where they are stuck.
Your problem is most likely connected with the fact that processes run in the control room are executed much faster than in studio and your webpage might not be loaded on time (that would explain why it works after retry).
Best practice approach would be to add a dynamic wait stage after attach and use “Parent Document Loaded” option on the element you want to interact with. It will wait for the page to be loaded and then check exist for the element. I would also suggest splitting your action into two, first to set start date and second for end date.

Open a dialog from a Sitecore uiUpload Pipeline process

I'm currently trying to show a SheerResponse.YesNoCancel() dialog within the Save uiUpload pipeline process from Sitecore. The problem appears when I do that call and it throws a NullException. I thought it was weird so I started copying the code from Sitecore's DLL and adding it to my solution. After that, I found that if the property OutputEnable is false it returns a ClientCommand that is NULL and when it tries to add a control to it, the Exception appears. So Fixing that I was able to finish the execution of that method. Anyway I still can't show the dialog. So the question is: Can I show a Dialog from a Sitecore uiUpload pipeline?
Have you tried using Sitecore.Context.ClientPage.ClientResponse.YesNoCancel(), i did something similar to what you are trying to do, but i used Alert(), worked fine for me.
Update: Actually inside uiUpload pipeline you can't call this method, however what you can do is use HttpContext.Current.Response.Write("<html><head><script type=\"text/Javascript\">[Your Java Script</script></head></html>"), you will need to abort the pipeline after this args.AbortPipeline();, not sure if this will help your case or not
No you cannot. From http://sdn.sitecore.net/Articles/Media/Prevent%20Files%20from%20Uploading.aspx:
The uiUpload pipeline is run not as part of the Sheer event, but as part of the form loading process in response to a post back. This is because the uploaded files are only available during the "real" post back, and not during a Sheer UI event. In this sense, the uiUpload pipeline has not been designed to provide UI.
That page was written for v5.1 and 5.2, but I'm pretty sure it still applies. The page claims that you can emit javascript to the page like Ahmed suggested, but it didn't work when I tried it.

Barcode scanner stops on Motorola MC 75A

I have a multi-form Windows mobile application that accesses the barcode scanner of the MC75 using the EMDK (version 2.6). I access the barcode scanner using a Singleton. When the application starts I call barcodereader.Actions.Enable() and when the application exits I call `barcodereader.Actions.Disable()'. Basically I've used the EMDK samples as a guide to get the scanner working.
While the application is running I add the event handler to the barcode reader `readNotify' on the form activation event and remove the event handler when the form activates. I have put code in to check that this is happening correctly and added a check to ensure no existing event handlers are present before a new one is added.
The application works fine but for some reason the barcode scanner suddenly cuts out and will not work when the trigger button is pressed. This always seems to happen in the same place (after around 20 odd scans spread across the three forms). No error is caught and the scanner light fails to come on. I have a set number of scans to do and the scanning stops on a form where I've done a successful scan seconds earlier. I can do more than 20 scans on a single form but I only seem to get the issue when doing scanning on different forms.
If I restart the application the scanner works again. The datawedge software is installed but is not used.
I have seen this issue during my research here, but my issue does not seem to be intermittent.
I saw a note on the Symbol support site stating it was not desirable to repeatedly call `.Actions.Enable' and '.Actions.Disable' when moving between forms and I don't do this.
I'm at a loss as to what to check in the application. Any ideas?
Details - using Windows Visual Studio 2008, device is running Windows Mobile 6.5 Professional, EMDK version 2.6, application written in C#.
I had this exact same issue on an MC70 device. Unfortunately it was at a previous employer so I no longer have the source code to look back on. I do remember having to create a somewhat ugly workaround to get it working.
I know that I ended up declaring/instantiating the barcodereader object inside of the parent form (so no need for the singleton class). Then every time I instantiated a child form, I passed either the parent form object or the barcodereader object BY REFERENCE into the child form. Then I was able to access it from the child form repeatedly without it crashing/locking up. I know that is a pretty vague description, but it's been a couple of years since I worked on that code. Hope this helps.
I knew this problem years ago!. The solution to that is: DON'T disable the barcode reader when doing form navigation (Keep it always Active ). It works perfectly for me (I did MC9062 6 years ago and now MC75A device). Just put some logic to tell your program to handle scanned data differently under different form.
Yes, it is important to use reader object as "Singleton".

Information Management Policy in SharePoint

An obscure puzzle, but it's driving me absolutely nuts:
I'm creating a custom Information Management Policy in MOSS. I've implemented IPolicyFeature, and my policy feature happily registers itself by configuring a new SPItemEventReceiver. All new items in my library fire the events as they should, and it all works fine.
IPolicyFeature also has a method ProcessListItem, which is supposed to retroactively apply the policy to items that were already in the library (at least, it's supposed to do that for as long as it keeps returning true). Except it doesn't. It only applies the policy to the first item in the library, and I have absolutely no idea why.
It doesn't seem to be throwing an exception, and it really does return true from processing that first item, and I can't think what else to look at. Anyone?
Edit: Cory's answer, below, set me on the right track. Something else was indeed failing -- I didn't find out what, since my windbg-fu isn't what it should be, but I suspect it was something like "modifying a collection while it's being iterated over". My code was modifying the SPListItem that's passed into ProcessListItem, and then calling SystemUpdate on it; as soon as I changed the code so that it created its own variable (pointing at the exact same SPListItem) and used that, the problem went away...
There's only a couple of things I can think of to try. First, are you developing on the box where you might be able to use Visual Studio to debug? So just stepping through it.
Assuming that's not the case - what I'd do is fire up WinDBG and attach it to the process just before I registered the policy. Turn on first chance exceptions so that it breaks whenever they occur. you can do that by issuing the command "sxe clr" once it is broken in. Here's a little more info about WinDBG:
http://blogs.msdn.com/tess/archive/2008/06/05/setting-net-breakpoints-in-windbg-for-applications-that-crash-on-startup.aspx
What I'd do is then watch for First Chance exceptions to be thrown, and do a !PrintException to see what is going on. My guess is that there is an exception being thrown somewhere that is causing the app to stop processing the other items.
What does the logic look like for your ProcessListItem? Have you tried just doing a return true to make sure it works?
Some nice ideas there, thanks. The Visual Studio debugger wasn't showing an exception (and I've wrapped everything in try/catch blocks just in case), but I hadn't thought of trying Windbg...

Resources