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

Need Help: How to set Component's Destination Dir


1 reply to this topic

Marsyas

Marsyas
  • Full Members
  • 31 posts

Posted 28 May 2008 - 12:56

Hi!

I'm trying to install a local printer during a Basic MSI Setup. I have written some C++ Code doing this for me and this code will be called during setup through a Custom Action.

Before I can call this code I need to copy the printer drivers to the System's printer driver directory (usually 'c:\Windows\System32\spool\drivers\w32x86'). The actual printer driver directory can be detected with the GetPrinterDriverDirectory() call.

Now is the question, how can I set the destination directory of the components containing my printer driver files to the directory pointed by GetPrinterDriverDirectory()?

I tried to write a Msi-DLL, which sets me a property with MsiSetProperty() and afterwards a second CA changes the Custom Path of the components to the dir pointed by the property.

Sample:
CODE

UINT __stdcall SetPrnDriverDirProp2(MSIHANDLE hMsi)
{
TCHAR szPrinterDriverDir[MAX_PATH];
DWORD cbPrinterDriverDir = sizeof(szPrinterDriverDir);

ZeroMemory(&szPrinterDriverDir, cbPrinterDriverDir);
if (!GetPrinterDriverDirectory(NULL, NULL, 1, (LPBYTE)szPrinterDriverDir, MAX_PATH, &cbPrinterDriverDir))
{
 /* some error handling */
}

TCHAR szTmp[MAX_PATH] = {0};
DWORD nLen = MAX_PATH;

ZeroMemory(szTmp, MAX_PATH);
UINT nRet1 = MsiGetProperty(hMsi, _T("SYSPRINTERDIRPROP"), szTmp, &nLen);
UINT nRet2 = MsiSetProperty(hMsi, _T("SYSPRINTERDIRPROP"), szPrinterDriverDir);

return ERROR_SUCCESS;
}


For some reason I'm not able to find out I always get a ERROR_INVALID_HANDLE as return code in nRet2. This makes no sense to me, because MsiGetProperty works fine, so the handle cannot be invalid :confused:.

Any suggestions?

Is there a more convenient way to set the target dir of the printer driver files?

Thank for your help

Marsyas

m.nouryan

m.nouryan
  • Full Members
  • 23 posts

Posted 28 May 2008 - 20:46

I have not changed the target directory of a component with this method BUT I use MsiSetProperty(ISMSI_HANDLE,...,...) in a custom action and it works for me.

Have you tried doing your stuff in a custom action instead of a DLL?

-Morteza