PDA

View Full Version : Window Handle in Managed Custom Action



teknix1
06-27-2008, 09:28 AM
Has anybody been able to figure out a way of getting the window handle to the installer? I want to move away from my InstallScript which currently passes this parameter to my .Net custom action.

In InstallScript this always (even in deferred mode) return the proper value:
hWindowHandle = GetWindowHandle( HWND_INSTALL );

In .Net, I am trying to call msi.dll apis or go from Process.GetCurrentProcess() and find my way back to a visible window but no luck. I was suggested to use FindWindow or EnumThreadWindows, I can't use FindWindow because it needs the window title and I may not have access to that, EnumThreadWindows for some reason can't seem to find my window...

InstallShield were not allowed to disclose the inner workings of GetWindowHandle so I don't have much to go on. I know that HWND_INSTALL is a constant equal to -2. Perhaps this is a parameter sent to a Windows api???

Any leads are highly appreciated.

Thanks
Nic

teknix1
06-27-2008, 10:44 AM
Did some more digging and found out that msiexec does sandboxing for certain things. My dll runs in a different sandbox than where the UI resides. So if I get the current process through Process.GetCurrentProcess() this pid is not representing the process which holds the windows so that explains why EnumThreadWindows does not work.

bryanwolf
06-27-2008, 11:06 AM
Could you clarify why you are looking for the handle to the UI in a Managed Custom Action?

teknix1
06-27-2008, 12:16 PM
I need the handle for two reasons.

1. Our installer currently already uses this method of showing messages/dialogs and it would be a big change in the code if we were to try to do this as a pure msi dialog. Actually I don't even think it would be possible.

2. This handle will allow me to display messages and other boxes that will be modal to the install wizard. I don't want them to be able to play with the wizard unless they have dismissed my dialog.