COM Callable Wrapper (CCW)

Dll in .Net and callable in vbscript..

1) CCW.cs
using System;
using System.Runtime.InteropServices;
namespace NMyCCW
{
[ClassInterface(ClassInterfaceType.AutoDual)]
public class ClsCOMServer
{
private string m_strName;
public ClsCOMServer(){}
public void SetName(string strName){m_strName = strName;}
public string GetName(){return m_strName ;}
}
}

2) csc /target:library CCW.cs — Make a dll

3) regasm ccw.dll /tlb:ccwtlb.tlb /codebase — Create a tlb.

4) use tlb in vbs—

Dim dotNetObj
Set dotNetObj = CreateObject(“NMyCCW.ClsCOMServer”)
dotNetObj.SetName (“Subodh”)
MsgBox “Name is ” & dotNetObj.GetName()

run as — wscript comclient.vbs

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s