[gptalk] Re: Add MSI package to GP

  • From: "Northwood, Ian" <Ian.Northwood@xxxxxx>
  • To: <gptalk@xxxxxxxxxxxxx>
  • Date: Wed, 17 Oct 2007 09:18:49 +0100

Aaaaaaarrrrrrrrggggghhhhhhhh! I'm *this* close...
The latest hurdle is using MsiAdvertiseScript API to create the AAS file and I 
believe the problem comes down to data types. Here's the deal.
I'm using the DynaWrap DLL to access the API. I've used this DLL successfully 
for years so I'm confident in its abilities, stability, etc. My code looks like 
this (much simplified):
Set objDLLWrapper = WScript.CreateObject("DynamicWrapper")
blnResult    = objDLLWrapper.Register("MSI.DLL", "MsiAdvertiseProductA", 
"i=ssst", "f=s", "r=l")
'// where
'//     i     defines the number and data type of the function's parameters
'//     f     defines the type of call, either _stdcall (use 's' - Microsoft 
C++) or _cdecl (use 'c' - Borland C++)
'//     r     defines the return data type. 
'// Data types are:
'//  {'a', sizeof(IDispatch*),    VT_DISPATCH}, // a   IDispatch*
'//  {'c', sizeof(unsigned char), VT_I4},       // c   signed char  
'//  {'d', sizeof(double),        VT_R8},       // d   8 byte real 
'//  {'f', sizeof(float),         VT_R4},       // f   4 byte real 
'//  {'k', sizeof(IUnknown*),     VT_UNKNOWN},  // k   IUnknown* 
'//  {'h', sizeof(long),          VT_I4},       // h   HANDLE 
'//  {'l', sizeof(long),          VT_I4},       // l   long 
'//  {'p', sizeof(void*),         VT_PTR},      // p   pointer 
'//  {'s', sizeof(BSTR),          VT_LPSTR},    // s   string 
'//  {'t', sizeof(short),         VT_I2},       // t   short 
'//  {'u', sizeof(UINT),          VT_UINT},     // u   unsigned int 
'//  {'w', sizeof(BSTR),          VT_LPWSTR},   // w   wide string 

lngReturn    = objDLLWrapper.MsiAdvertiseProductA(strMSIFile, strAASFile, 
strMSTFile, intLanguage)
I've made sure that my strings (strMSIFile, strAASFile, strMSTFile) are 
explicitly defined as strings (using CStr) and my integer, intLanguage, is 
defined as an integer which, according to what I can find, is the nearest 
equivalent to LANGID.
The reason that I suppose it's a data type issue is that if I remove the string 
coercion from strMSIFile, strAASFile and strMSTFile, I get the value '2' 
returned in lngReturn. Put it back and I get '123'. I've tried adding null - 
Chr(0) - and vbNull to the end of the strings and using 'w' type for the string 
data type but I get the same results.
So, given the data type choices I have above, which should I be using for each 
function's parameters? I believe it's the integer which is the troublesome one: 
I've tried 'l', 't' and 'u'. In each case, I get '123' in lngReturn.
Intriguingly (or annoyingly, depending on how many times I've re-run the damn 
thing), I can transplant my code more or less intact into a VB.Net project and 
it works. The principle difference is that I've used Int16 as the data type for 
LANGID. Now, obviously I could create a DLL from VB.Net and simply use that. 
However, I want to have a solution which I could leave with my client which 
allows them the flexibility of VB Script, not tie them into maintaining DLLs 
with Visual Studio.
Thanks again.

Liverpool Victoria Friendly Society Ltd. Registered in England and Wales. 
Registered Office: County Gates Bournemouth England, BH1 2NF, No.61 Coll. 
Financial Services Authority Register number 110035.

This email (and any attachments):

- is for its intended recipients only and may contain confidential and/or 
legally privileged information. If received in error, any use of this email is 
Please delete it (and any copies) and notify us on +44(0)1202 292333, ext. 

-  is believed to be free of any virus or other defect but internet 
communications cannot be guaranteed to be secure or error free and we do not 
accept any liability for any loss or damage from their receipt or use.  
Opinions expressed in this email are not necessarily those of the Society. 

LV= and Liverpool Victoria are trade marks of Liverpool Victoria Friendly 
Society Limited and LV= and LV= Liverpool Victoria are trading styles of the 
Liverpool Victoria group of companies. 
LV= reserves the right to monitor and inspect emails sent to and by its 
employees.  To find out more about us please visit: www.lv.com

This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 

Other related posts: