Skip to content

Instantly share code, notes, and snippets.

@rphillips
Created June 14, 2015 22:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rphillips/cc82312ce59d4c3cdf7c to your computer and use it in GitHub Desktop.
Save rphillips/cc82312ce59d4c3cdf7c to your computer and use it in GitHub Desktop.
local Error = require('core').Error
local ffi = require('ffi')
local fmt = require('string').format
ffi.cdef[[
typedef unsigned long MSIHANDLE;
typedef unsigned int UINT, DWORD;
typedef char CHAR;
typedef CHAR *NPSTR, *LPSTR, *PSTR;
typedef const CHAR *LPCSTR, *LPTSTR, *LPCTSTR, *PCSTR;
enum {
ERROR_SUCCESS = 0L,
ERROR_MORE_DATA = 234L
};
UINT MsiOpenPackageA(const char* szPackagePath, MSIHANDLE *hProduct);
UINT MsiGetProductPropertyA(MSIHANDLE hProduct, LPCTSTR szProperty, LPTSTR lpValueBuf, DWORD *pcchValueBuf);
UINT MsiCloseHandle(MSIHANDLE hAny);
]]
local msilib = ffi.load("Msi")
local msi_path = 'out.msi'
local phProduct = ffi.new('MSIHANDLE[1]')
local ret = msilib.MsiOpenPackageA(msi_path, phProduct);
if ret ~= ffi.C.ERROR_SUCCESS then
error(ret)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment