March 01, 2001
Customizing Windows Installer
Listing 3: cadll.cpp Finding shared files
#include "stdafx.h"
#include <stdio.h>
#include <MsiQuery.h>
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call )
{
case DLL_PROCESS_ATTACH:
break;
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
UINT __stdcall FindShared(MSIHANDLE hInstall)
{
HKEY hk;
long res = RegOpenKeyEx (HKEY_LOCAL_MACHINE,
"Software\\MyCompany\\MyProduct\\MyFiles",
0, KEY_READ, &hk);
DWORD inx;
char thevalue [MAX_PATH] = {0};
DWORD buflen;
DWORD type;
for (inx=0; 1; inx++ )
{
buflen = sizeof(thevalue);
long regres = RegEnumValue(hk, inx, thevalue,
&buflen, NULL, &type, NULL, NULL);
if (ERROR_SUCCESS==regres)
{
_strlwr (thevalue);
char* pf = strstr (thevalue, "another.exe");
if (pf!=NULL)
{
MsiSetProperty(hInstall, "FOUNDANOTHER", thevalue);
break;
}
}
else
break;
}
RegCloseKey (hk);
return 0;
}
//End of File
| |||||||||