Solved

ActiveX exe and Web application

Posted on 2001-07-12
15
249 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
ID: 6276542
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
ID: 6276551
Allso remove the Set uUserForm from all the subs except

Launch

Vin.
0
 
LVL 4

Expert Comment

by:VincentLawlor
ID: 6276558
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
ID: 6277030
It didn't do any difference - still doesn't display the form.
0
 
LVL 4

Expert Comment

by:VincentLawlor
ID: 6277053
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
ID: 6277253
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
ID: 6277416
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:shlomof
ID: 6277740
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
ID: 6277788
Have you tried debugging into the ActiveX exe ?
0
 

Author Comment

by:shlomof
ID: 6277861
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
ID: 6277886
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
ID: 6307657
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
ID: 6307679
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
ID: 6307681
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
ID: 7116026
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

863 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

20 Experts available now in Live!

Get 1:1 Help Now