On Thu, 16 Apr 2009 22:58 -0700, "Rob Mensching" <r...@wixtoolset.org>
wrote:
> 1. MSI SDK says the RemoveFolders only removes a folder if it is empty.  
> You need a CustomAction to recurse all of the directories and add them 
> to the RemoveFolders table plus add the files to RemoveFiles table.

Well, I'm getting started writing that CustomAction. It's still 80%
psuedocode and only 20% C, but here's what I have so far. (I know I
can't append to strings like that in C, I'll rewrite that in proper RTL
calls myself when I get to my Visual Studio machine.)

I would prefer to have it run after the MSI has deleted the files it
knows about already. (why make extra work?)

What XML code would be required to put the CA in at that point, and what
MSI SDK functions would I use to do what is asked for in the HELP
comments?

I know I'm asking for a lot at the moment, but even if you only point
out the first steps, or point me to examples, I can work with that and
ask more detailed questions as needed later.

(Terms of Perl means the choice of the Artistic license, or GPL version
1 or later - don't blame me if that's a problem for people here, I'm
including this in a package that has that license.)

----------- CleanFolderCA.c

// This code is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.

#include "CleanFolderCA.h"

BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID
lpReserved )
{
    return TRUE;
}

UINT __stdcall CleanFolder ( MSIHANDLE hModule )
{
        LPCTSTR sInstallDirectory;
        UINT uiAnswer;
        
        // HELP: Query hModule for installation directory. [INSTALLDIR]
        property, IIRC.
        // Answer needs to eventually go into sInstallDirectory. 
        
        uiAnswer = AddDirectory(hModule, sInstallDirectory);
        
        if (uiAnswer != ERROR_SUCCESS) {
                return uiAnswer;
        }

        // HELP: Can I make the MSI action repeat this way, and is this
        the correct name?
        uiAnswer = MsiDoAction(hModule, _T("RemoveFiles"));
        
    return uiAnswer;
}

UINT __stdcall AddDirectory ( MSIHANDLE hModule, LPCTSTR sDirectory )
{
        LPCTSTR sFind = sDirectory + "\\*";
        LPCTSTR sNewDir;
        LPWIN32_FIND_DATA lpFound;
        HANDLE hFindHandle;
        UINT uiFoundFilesToDelete = 0;
        BOOL bAnswer = FALSE;
        UINT uiAnswer = ERROR_SUCCESS
        
        hFindHandle = FindFirstFile(sFind, lpFound);
        
        if (hFindHandle != INVALID_HANDLE_VALUE) {
                bAnswer = TRUE;
        }
        
        while (bAnswer & (uiAnswer == ERROR_SUCCESS))
                if (lpFound->dwFileAttributes &&
                FILE_ATTRIBUTES_DIRECTORY) {
                        sNewDir = sDirectory;
                        sNewDir += "\\";
                        sNewDir += lpFound + cFileName; 
                        uiAnswer = AddDirectory(hModule, sNewDir);
                } else {
                        uiFoundFilesToDelete++;
                }
        
                bAnswer = FindNextFile(hFindHandle, lpFound);
        }
        
        FindClose(hFindHandle);

        if (uiAnswer != ERROR_SUCCESS) {
                return uiAnswer;
        }
        
        if (uiFoundFilesToDelete > 0) {
                // HELP: Add entry to RemoveFiles table for *.* in this
                directory
        }
        
        // HELP: Add entry to RemoveFiles table for this directory with
        empty filename
        // (in order to delete the directory)
        
        return uiAnswer;
}
 
> 2.  I vaguely rememeber some tricky limitations around Shortcut Icons in 
> MSI.  You might try reading about those topics in the MSI SDK.

Found that problem, thanks!  Had to make sure that the Id attributes
ended with .ico, and everything worked. (The way the documentation and
tutorials read, I thought the ID attributes had to end with the
extension of the object being pointed to, instead, and of course,
reading an icon from what it thought was a .bat file had funny results!)

--Curtis
--
Curtis Jewell
swords...@csjewell.fastmail.us

%DCL-E-MEM-BAD, bad memory
-VMS-F-PDGERS, pudding between the ears

[I use PC-Alpine, which deliberately does not display colors and pictures in 
HTML mail]


------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to