Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / February 2006

Tip: Looking for answers? Try searching our database.

Implementing IActiveScriptSite and IActiveScriptSiteWindow in VB.N

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
GeorgeGilbot - 24 Feb 2006 17:01 GMT
I am writing a script host in VB.NET by implementing hand written
IActiveScriptSite and IActiveScriptSiteWindow interfaces on a class.

IActiveScriptSite methods are called successfully by a VBScript engine,
however IActiveScriptSiteWindow methods aren't. The consequence of this is
that VBScript will error when a MsgBox function is called.

Is it possible to write the class and interfaces so that the VBScript engine
can call methods on both interfaces.

Some code snippets:

<InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
Guid("BB1A2AE1-A4F9-11cf-8F20-00805F2CD064")> _
Interface IActiveScript

   Sub SetScriptSite(<[In](), MarshalAs(UnmanagedType.Interface)> ByVal
site As IActiveScriptSite)
.
.
.

<InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
Guid("DB01A1E3-A42B-11cf-8F20-00805F2CD064")> _
Interface IActiveScriptSite

   Sub GetLCID(ByRef id As System.UInt32)
.
.
.
<InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
Guid("D10F6761-83E9-11cf-8F20-00805F2CD064")> _
Interface IActiveScriptSiteWindow
   Sub GetWindow(ByRef phwnd As IntPtr)

   Sub EnableModeless(ByVal fEnable As Int32)
End Interface
.
.
.
Public Class ScriptHost
   Implements IActiveScriptSite
   Implements IActiveScriptSiteWindow
.
.
.

Create the VBScript engine and run script:
       Dim scriptEngine As New VBScript
       Try
           Dim iasp As IActiveScriptParse
           iasp = CType(scriptEngine , IActiveScriptParse)
           iasp.InitNew()
           Dim ias As IActiveScript
           ias = CType(scriptEngine , IActiveScript)

           ias.SetScriptSite(Me)

           Dim sss As String = "MsgBox " & Chr(34) & "test" & Chr(34) &
vbCrLf
           iasp.ParseScriptText("MsgBox " & Chr(34) & "test " & Chr(34) &
vbCrLf, Nothing, Nothing, vbCrLf, Nothing, 0, 2, Nothing, Nothing)
           ias.SetScriptState(2)
           ias.Close()



Thanks in advance
GeorgeGilbot - 28 Feb 2006 13:11 GMT
Further to this I wrote a test scripting engine. In the engine's
SetScriptSite() method, calling QueryInterface for IActiveScriptSiteWindow on
the passed IActiveScriptSite failed with E_NOINTERFACE. I'm not sure of what
to do next to find out what's happening.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.