Using DLLs in VBScript

I compiled C # code in a DLL, but I have little experience with them. My C # code contains a HelloWorld class with a static Print() method. I would like to use this DLL in VBScript to call the Print() method. I know this is the base, but I use it as a test for a larger project that will eventually be compiled into a DLL. What does the declaration look like for this, and what will the method call look like?

+8
c # dll vbscript
source share
3 answers

If your dll is registered on the system, use CreateObject with its ProgID.

 Set myObject = CreateObject("MyReallyCoolObject.HelloWorld") myObject.Print 

If your object is not registered in the system, use GetObject with the path to the file containing your object. Make sure your object provides the correct interface. (The second parameter is optional. Here you can specify the class name if your object provides more than one.)

 Set myObject = GetObject("C:\some\path\helloworld.dll", "appname.HelloWorld") myObject.Print 
+17
source share

I think you can search without registering COM . This SO answer regarding Microsoft.Windows.ActCtx should help specifically for VBScript.

Keep in mind that COM does not support static methods, so you have to make your Print method in the instance method.

+1
source share
0
source share

All Articles