cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
kentfishman
Level 3

help in calling MsiSourceListGetInfo

I want to be able to retrieve the msi package name. If there is an easier way to do this other than trying to use MsiSourceListGetInfo,
I would appreciate it.

Here are the pertinent code pieces I have included in setup.rul to try to use MsiSourceListGetInfo
////////////////////////////////////////////////////////////////////////

#include "ifx.h"
#include "iswi.h"
#include "isrt.h"

#define MSICODE_PRODUCT 0x00000000L // product code provided
#define MSIINSTALLCONTEXT_MACHINE 4

prototype NUMBER msi.MsiSourceListGetInfo(BYREF STRING, BYREF STRING, NUMBER, NUMBER, BYREF STRING, BYREF STRING, BYREF NUMBER);

function myfunction()
...
...
begin
szProductCode="{3251536B-F670-4C69-B5E9-36697BE36617}";
szUserID="";
nContext=MSIINSTALLCONTEXT_MACHINE;
nOptions=MSICODE_PRODUCT;
szProperty=INSTALLPROPERTY_PACKAGENAME;

nReturn = MsiSourceListGetInfo(szProductCode, szUserID, nContext, nOptions, szProperty, szValue, nValue);
...
...
end;

Everything compiles ok, but when I run it, I get an error message saying it failed to find the dll function. Do I have to include the MSI.dll and use UseDLL and UnUseDLL?
Labels (1)
0 Kudos
(1) Reply
RobertDickau
Flexera Alumni

It depends when you're trying to get this information: if you're getting it from the running first-time installation, you might call MsiGetProperty to get the "OriginalDatabase" property (described in the MSI help file) and then parse it to get the file name.

If you do need to call the DLL function later, maybe check (using Dependency Walker or depends.exe) if the function is split into ANSI (MsiSourceListGetInfoA) and Unicode (-GetInfoW) varieties, where there might not be an undecorated (without -A or -W) version.
0 Kudos