Solved

ActiveX exe and Web application

Posted on 2001-07-12
15
247 Views
Last Modified: 2008-03-17
What I want to do is, once Web application is launched, ActiveX exe to launch a form which will behave as a monitor. It should display number of current user of the web application and last session id that entered the application and last session id that left the application.

What I did, I wrote a simple ActiveX exe with a form that displays 3 text areas to display each of the parameter. In the web application, the job is done by global.asa.  But it doesn't work.  Any idea what am i doing wrong?  Follows the code:

Users.exe  Class Module formControl.cls
----------------------------------------
Private uUserForm As userDataForm


Public Sub launchForm()
   Set uUserForm = New userDataForm
   Load uUserForm
End Sub


Public Sub shutForm()
   Unload uUserForm
   Set uUserForm = Nothing
End Sub

Public Sub activeUsers(iActiveUsers)
   Set uUserForm = New userDataForm
   uUserForm.Text1 = iActiveUsers
End Sub


Public Sub connectedSession(SessionID)
   Set uUserForm = New userDataForm
   uUserForm.Text2 = SessionID
End Sub


Public Sub disconnectedSession(SessionID)
   Set uUserForm = New userDataForm
   uUserForm.Text3 = SessionID
End Sub

And web application global.asa:
-------------------------------

<SCRIPT LANGUAGE=VBScript RUNAT=Server>

Sub Application_OnStart
     Application("ACTIVEUSERS") = 0
     set Application("objExe") = Server.CreateObject("Users.formControl")
     call Application("objExe").launchForm()
End Sub


Sub Application_OnEnd
     call Application("objExe").shutForm()
     set Application("objExe") = nothing
End Sub



Sub Session_OnStart
     Application.Lock
          Application("ACTIVEUSERS") = Application("ACTIVEUSERS") + 1
     Application.UnLock
     call Application("objExe").activeUsers(Application("ACTIVEUSERS"))
     call Application("objExe").connectedSession(session.SessionID)
End Sub


Sub Session_OnEnd
     Application.Lock
          Application("ACTIVEUSERS") = Application("ACTIVEUSERS") - 1
     Application.UnLock
     call Application("objExe").activeUsers(Application("ACTIVEUSERS"))
     call Application("objExe").disconnectedSession(session.SessionID)
End Sub

</SCRIPT>

0
Comment
Question by:shlomof
  • 9
  • 5
15 Comments
 
LVL 4

Expert Comment

by:VincentLawlor
Comment Utility
In launchForm

add the line uUserForm.Show

I have your code working in VB
0
 
LVL 4

Accepted Solution

by:
VincentLawlor earned 50 total points
Comment Utility
Allso remove the Set uUserForm from all the subs except

Launch

Vin.
0
 
LVL 4

Expert Comment

by:VincentLawlor
Comment Utility
Here's the code for your ActiveX Exe

Option Explicit

Private uUserForm As userDataForm


Public Sub launchForm()
  Set uUserForm = New userDataForm
  Load uUserForm
  uUserForm.Show
End Sub


Public Sub shutForm()
  Unload uUserForm
  Set uUserForm = Nothing
End Sub

Public Sub activeUsers(iActiveUsers)
  'Set uUserForm = New userDataForm
  uUserForm.Text1 = iActiveUsers
  uUserForm.Text1.Refresh
End Sub


Public Sub connectedSession(SessionID)
  'Set uUserForm = New userDataForm
  uUserForm.Text2 = SessionID
  uUserForm.Text2.Refresh
End Sub


Public Sub disconnectedSession(SessionID)
  'Set uUserForm = New userDataForm
  uUserForm.Text3 = SessionID
  uUserForm.Text3.Refresh
End Sub

Vin.

0
 

Author Comment

by:shlomof
Comment Utility
It didn't do any difference - still doesn't display the form.
0
 
LVL 4

Expert Comment

by:VincentLawlor
Comment Utility
Have a look in your task list and see if your exe has been launched.

The code definately works from VB.

I presume you copied and pasted the code above and recompiled the exe.

Vin.
0
 

Author Comment

by:shlomof
Comment Utility
As soon as I launch the web application, I can see the exe is launched in the task list and as soon as I stop the IIS, the exe is being stopped.

From VB it is a different story - it will probably work because it is used by the same user.  When you use it from web application, it is different story and currently it doesn't work and this is exactly my problem.
0
 
LVL 4

Expert Comment

by:VincentLawlor
Comment Utility
If you can see it in the task list then the Form show is not being called check the code.

Your exe will be called from the same apartment as your webbrowser so that shouldn't be an issue.

You can check what is happening by opening your project in dev studio and put a break point in the launchForm sub.

Choose Wait For components to be created.

Try and run it from your VBScript

Vin.
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:shlomof
Comment Utility
It doesn't work from web application. Here is the code again:

VB Code:
--------

Private uUserForm As userDataForm


Public Sub launchForm()
   Set uUserForm = New userDataForm
   Load uUserForm
   uUserForm.Show
End Sub


Public Sub shutForm()
   Unload uUserForm
   Set uUserForm = Nothing
End Sub

Public Sub activeUsers(iActiveUsers)
   'Set uUserForm = New userDataForm
   uUserForm.Text1 = iActiveUsers
   uUserForm.Text1.Refresh
End Sub


Public Sub connectedSession(SessionID)
   'Set uUserForm = New userDataForm
   uUserForm.Text2 = SessionID
   uUserForm.Text2.Refresh
End Sub


Public Sub disconnectedSession(SessionID)
   'Set uUserForm = New userDataForm
   uUserForm.Text3 = SessionID
   uUserForm.Text3.Refresh
End Sub


And the web application is:

global.asa
----------

<SCRIPT LANGUAGE=VBScript RUNAT=Server>

Sub Application_OnStart
     Application("ACTIVEUSERS") = 0
     set Application("objExe") = Server.CreateObject("Users.formControl")
     Application("objExe").launchForm()
End Sub


Sub Application_OnEnd
     objExe.shutForm()
     set objExe = nothing
End Sub



Sub Session_OnStart
     Application.Lock
          Application("ACTIVEUSERS") = Application("ACTIVEUSERS") + 1
     Application.UnLock
     Application("objExe").activeUsers(Application("ACTIVEUSERS"))
     Application("objExe").connectedSession(session.SessionID)
End Sub


Sub Session_OnEnd
     Application.Lock
          Application("ACTIVEUSERS") = Application("ACTIVEUSERS") - 1
     Application.UnLock
     Application("objExe").activeUsers(Application("ACTIVEUSERS"))
     Application("objExe").disconnectedSession(session.SessionID)
End Sub

</SCRIPT>


and just a page in the web application:

activeX1.asp
------------

<%@ Language=VBScript %>
<%
Response.Write "This is session = " & session.SessionID
%>


Try it yourself.  It's just doesn't display the form.
0
 
LVL 4

Expert Comment

by:VincentLawlor
Comment Utility
Have you tried debugging into the ActiveX exe ?
0
 

Author Comment

by:shlomof
Comment Utility
How can I debbug it when I execute it from web application? As I mentioned, if I create a VB test project, it does display the form.  It just doesn't from web application.
0
 
LVL 4

Expert Comment

by:VincentLawlor
Comment Utility
What I mean is load up the project and follow the instructions I gave previously.

Your VB application will break at the breakpoint you have set.

Vin.
0
 

Author Comment

by:shlomof
Comment Utility
VincentLawlor,

FYI, it is impossible to do what I wanted to do.  Your suggestions aren't working.  They work from VB but not from web application.  The reason is that to run such a 'monitor', it needs a certain desktop to run on.  And on which desktop will it run?

Anyway, I will give you the points for the efford.  Thnx :)
0
 
LVL 4

Expert Comment

by:VincentLawlor
Comment Utility
Thanks.

Sorry to hear that :-(

Sounds like you would have to install Dev Studio on the web server and debug from there.

Vin.

0
 
LVL 4

Expert Comment

by:VincentLawlor
Comment Utility
Thanks.

Sorry to hear that :-(

Sounds like you would have to install Dev Studio on the web server and debug from there.

Vin.

0
 
LVL 17

Expert Comment

by:inthedark
Comment Utility
shlomof, it is possible to do this....
You can create a Windows  NT/2000 service which is updated by the global.asa and your asp. So turn your activex exe into a service.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now