Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Basic MSI Custom Dialogs


2 replies to this topic

MichaelA

MichaelA
  • Members
  • 4 posts

Posted 06 August 2003 - 19:09

Hi,
I'm trying to create a DLL that contains a DialogBox to do some configuration of the User Data.
The trouble I'm running into is that the ::CreateDialog wants an HINSTANCE. I'm sure there must be a way to do this but at the moment it seems to elude me. If anyone has any thoughts on this it would be helpful.


Here is the code I'm using, the problem is that using this method the ::CreateDialog call can't load the resource which leads me to believe that I don't have a valid ModuleHandle.

UINT __stdcall Config(MSIHANDLE hInstall)
{
MessageBox(GetForegroundWindow(), "test", "test", MB_OKCANCEL);
DebugBreak();

HINSTANCE hInst = GetModuleHandle(NULL);
DWORD DlastError = GetLastError();

HWND hWnd = ::CreateDialog(hInst, MAKEINTRESOURCE(IDD_DIALOGCONFIG), 0, (DLGPROC)DialogProc);
DlastError = GetLastError();
if (hWnd == 0)
return 2;
::SetDlgItemText(hWnd, 8, "Configuration");
::ShowWindow(hWnd, SW_SHOW); //!! why do we need this?
MSG msg;
while (::GetMessage(&msg, 0, 0, 0) == TRUE)
::IsDialogMessage(hWnd, &msg);
::destroyWindow(hWnd);
return msg.wParam;

If anyone has any thoughts on this it would be helpful.


Neo

Neo
  • Members
  • 48 posts

Posted 12 August 2003 - 12:40

Hello Michael

An easier way to create a dialog for MSI is to use the Dialog View. You can choose from the three templates provided and add your controls to the dialog. If you need to call Custom code that needs to work with these properties you can either use InstallScript or a Windows Installer DLL. Creating a Windows Installer DLL is not very difficult. Please follow this link to the InstallShield Article written by Rober Dickau on creating a Windows Installer DLL.

http://www.installsh...ls-for-ipwi.asp

I hope this provides a solution for your issue.

Regards

Neo

Ian Blake

Ian Blake
  • Members
  • 483 posts

Posted 13 August 2003 - 03:47

I think GetModuleHandle returns a handle to the current process ie. MsiExec.
This module does not contain your dialog box you need the hModule of your dll for the dialog template.
When your dll is loaded "DllMain" is called with the hModule of the dll so you can copy that into thread local storage ready for later use.


Ian Blake
(Currently Unemployed)