C# Call back function - Evalcom2

J

Josh M

Hi,

I am trying to use the EvalCom2.dll to validate a MSI -
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/ivalidate_setstatus.asp

I have the following code so far...

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Security.Permissions;
namespace MsiIce
{
public delegate int DisplayVal ( IntPtr pContext , Int32 uiType ,
string szwVal , string szwDescription , string szwLocation );
public delegate bool Evalcomcallback ( Int32 iStatus , string
szwData , IntPtr pContext );

[GuidAttribute ( "6E5E1910-8053-4660-B795-6B612E29BC58" )]
[ClassInterfaceAttribute ( ClassInterfaceType.None )]
[ComImportAttribute ()]
[SecurityPermission ( SecurityAction.Demand , UnmanagedCode = true
)]
class EvalClass
{
[DllImport ( "evalcom2.dll" )]
public static extern int LPDisplayVal ( DisplayVal x , IntPtr y
);
public static extern int LPEVALCOMCALLBACK ( Evalcomcallback x
, IntPtr y );
}
[InterfaceTypeAttribute ( ComInterfaceType.InterfaceIsIUnknown )]
[GuidAttribute ( "E482E5C6-E31E-4143-A2E6-DBC3D8E4B8D3" )]
[ComImportAttribute ()]

public interface IValidate
{
Int32 OpenDatabase ( [MarshalAs ( UnmanagedType.LPWStr )]
string szDatabase );
Int32 CloseDatabase ( );
Int32 OpenCUB ( [MarshalAs ( UnmanagedType.LPWStr )] string
szCUBFile );
Int32 CloseCUB ( );
Int32 Validate ( [MarshalAs ( UnmanagedType.LPWStr )] string
szICEs );
Int32 SetDisplay ( [MarshalAs ( UnmanagedType.LPWStr )]
DisplayVal pDisplayFunction , IntPtr pContext );
Int32 SetStatus ( [MarshalAs ( UnmanagedType.LPWStr )]
Evalcomcallback pStatusFunction , IntPtr pContext );

}


}

I do not understand how to use this code with a program to preform the
function I need to validate the MSI..Any help will be great.. thank you
Josh
 
Z

Ziad Elmalki

Here is an example. I dont know much about the msi stuff

class EvalClass
{
[DllImport ( "evalcom2.dll" )]
public static extern int LPDisplayVal ( DisplayVal x , IntPtr y
);
public static extern int LPEVALCOMCALLBACK ( Evalcomcallback x
, IntPtr y );

public static bool IsValid ( Evalcomcallback x
, IntPtr y )
{
EvalHandler _EvalHandler = new EvalHanlder();
LPEVALCOMCALLBACK _Handler = new LPEVALCOMCALLBACK ( EvalHandlerMethod);

return _EvalHandler._IsValid;

}



private bool EvalHandlerMethod ( STATUSTYPES iStatus,
LPCWSTR szwData,
LPVOID pContext )
{
return iStatus == ieStatusSuccess;
}


private bool _IsValid = false;

private EvalHandler()
{

}

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top