In QTP, you can use dotnetfactory object to access .net objects. You must have .net framework installed in your system before you use createinstance method.
Syntax
Here
Typename - any type name that .net framework provides example - System.Environment
Example
The following example uses the CreateInstance method to create a object of a system environment type
Set obj = Dotnetfactory.CreateInstance("System.Environment")
print obj.MachineName
Set obj = Dotnetfactory.CreateInstance("System.Math")
print cstr(obj.Abs(-12))
It enables you to create an instance of a .NET object, and access
its methods and properties.
Description
Createinstance method returns a COM interface for a .NET object.
Syntax
Set myobj = DotNetFactory.CreateInstance (TypeName [,Assembly] [,args])
Here
Typename - any type name that .net framework provides example - System.Environment
Example
The following example uses the CreateInstance method to create a object of a system environment type
Set obj = Dotnetfactory.CreateInstance("System.Environment")
print obj.MachineName
Set obj = Dotnetfactory.CreateInstance("System.Math")
print cstr(obj.Abs(-12))
No comments:
Post a Comment
Please Leave your reply. We value your feedback and inputs