The following is a section of Jscript to call the Message Box object from System.Windows.Forms within a script type ITSM Function. It can be called using Alert(“text in here”); or Alert(+variable name);
//The following function presents a message box to the user when //called using Alert(“text in here”); or Alert(+variable name);
function Alert
(
Message : System.String
)
{
var asm : System.Reflection.Assembly
var typ_win : System.Type
//Get the main form object from the remote type
try
{
//Get a pointer to the System.Windows.Forms assembly
asm = System.Reflection.Assembly.LoadWithPartialName("System.Windows.Forms");
//Get the MessageBox type from System.Windows.Forms
typ_win = asm.GetType("System.Windows.Forms.MessageBox");
//Execute the Show method of the Message box object
var argMSG : System.Object[]
argMSG = new System.Object[1] ;
argMSG[0] = Message;
typ_win.InvokeMember
(
"Show", //The member name
System.Reflection.BindingFlags.InvokeMethod, //Binding Flags
null, //Binder
null, //Object
argMSG //Arguments
);
}
catch(exc : System.Exception){}
}
1 comment:
CamDS , do you have somescreenshots to support this funtion? I can't get it to work...
Post a Comment