[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  VBscript
. . -> [Subject]  ActiveX and COM wrapper
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

ActiveX and COM wrapper

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Dlong   (1 post)  [Biography] bio
Date Tue 27 Sep 2005 04:09 PM (UTC)
Message
What is the difference between the ActiveX and COM wrapper?
[Go to top] top

Posted by Shadowfyr   USA  (1,783 posts)  [Biography] bio
Date Reply #1 on Tue 27 Sep 2005 07:20 PM (UTC)

Amended on Tue 27 Sep 2005 07:22 PM (UTC) by Shadowfyr

Message
A "wrapper" refers to code created to allow a program to link to something else. Most DLLs that are not ActiveX use these, including the Windows API. An example of the difference would be:


<Wrapper>
---------
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long

<Script>
--------
'Search the window
WinWnd = FindWindow(vbNullString, "MUSHClient")
If WinWnd = 0 Then MsgBox "Couldn't find the window ...": Exit Sub
'Show the window
ShowWindow WinWnd, SW_SHOWNORMAL

So, basically a wrapper is a set of definitions that specify 'which' DLL something is in, such as "user32", and 'what' parameters they expect. ActiveX uses something called IUnknown, to access an internal 'wrapper', which contains these same definitions, for those functions available to programs. Instead of explicitly defining what functions you want to use, you create a copy of the DLL, then refer to the internal functions. If "user32" was an ActiveX component, then using it would look like this:

a = createobject("User32API")
WinWnd = a.FindWindow(vbNullString, "MUSHClient")
a.ShowWindow WinWnd, SW_SHOWNORMAL

The reasion being that 'createobject' automatically reads the internal definitions using IUnknown (the ActiveX wrapper), and provides immediate access to the functions. Since standard DLLs do not contain their own internal table, they require a 'wrapper' to tell your program what to do with them. Mushclient itself comes with a file called MUSHClient.tlb, which VB Studio and other programs that know how to read them can generate their own wrappers from. Python includes something to do this, and probably Lua as well, otherwise you end up having to write your own.

Some things like VBScript are intentionally disabled on some levels, so such wrappers can't be created for them. The idea was to keep someone from linking to the file system API or the like and causing the system to tranfer files, delete them, format your hard drive, etc. Its didn't work, since all it takes to do those things anyway is to get some fool to install an ActiveX program, and in some cases even force IE to install one without you knowing, then use createobject to do the same thing anyway... The result is that all MS based script systems are useless as full languages, since none of them can access APIs or non-ActiveX components. As my father sometimes says, "It just keeps the honest criminals from taking advantage of you.", wihout really doing what that limitation was supposed to prevent.
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


7,654 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]