Consultor Eletrônico



Kbase P32172: How to add ActiveX Proxy with Webclient Application Assemble
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   11/13/2003
Status: Unverified

GOAL:

How to add ActiveX Proxy with Webclient Application Assembler.

FACT(s) (Environment):

Windows

FIX:

The WebClient Assembler doesn't have a built in function to register an ActiveX Proxy.
Programmatically using the IntelliStream IntelliStream 4GL Install Procedure to make changes to the environment.

To Change the System Environment variable modify the follow Registry key:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment
You can make keys programmatically here or modify keys for existing environment variables using the put-key-value function.

On Win9x class machines you could append to the autoexec.bat adding lines similar to:
set CLASSPATH=%CLASSPATH%;<new value>

This change will not be immediately available to the session. A system reboot is one method to allow this change to be propagated globally to the system.

The other option would be to employ code similar to the following:
/* Run the post installation Progress Programs */

def var oldversion as char.
def var newversion as char.
def var cmd as memptr.
def var wresult as INTEGER.


/* Windows Constants for the SendMessageTimoutA API */
&GLOB WM_SETTINGCHANGE 26
&GLOB HWND_BROADCAST 65535
&GLOB SMTO_ABORTIFHUNG 2

/* Broadcast the Environment change to anyone interested */
/*http://support.microsoft.com/default.aspx?scid=kb;en-us;104011 */
PROCEDURE SendMessageTimeoutA EXTERNAL "USER32.DLL":
DEFINE INPUT PARAMETER win-handle AS LONG NO-UNDO.
DEFINE INPUT PARAMETER win-msg AS LONG NO-UNDO.
DEFINE INPUT PARAMETER win-param1 AS LONG NO-UNDO.
DEFINE INPUT PARAMETER win-param2 AS LONG NO-UNDO.
DEFINE INPUT PARAMETER fuflags AS LONG NO-UNDO.
DEFINE INPUT PARAMETER timeout AS LONG NO-UNDO.
DEFINE output PARAMETER wResult AS LONG NO-UNDO.
END PROCEDURE.

/* Temporarly update environment of any child processes
used for the OS-COMMAND regsvr32
*/
PROCEDURE SetEnvironmentVariableA EXTERNAL "kernel32.dll" :
DEFINE INPUT PARAMETER lpName AS CHAR NO-UNDO.
DEFINE INPUT PARAMETER lpValue AS CHAR NO-UNDO.
DEFINE RETURN PARAMETER iret AS LONG NO-UNDO.
END.


DEFINE VARIABLE iret AS INTEGER NO-UNDO.
DEF VAR CLASSDATA AS CHAR NO-UNDO.
DEF VAR WCPATH AS CHAR NO-UNDO.

/* Get the WC Applications Path */
FUNCTION getWCPath RETURNS CHARACTER ().
DEF VAR lwcp AS CHARACTER.

LOAD "SOFTWARE" BASE-KEY "HKEY_LOCAL_MACHINE".
USE "SOFTWARE".

GET-KEY-VALUE SECTION "PSC\WebClient"
KEY "ApplicationsPath"
VALUE lwcp.

UNLOAD "SOFTWARE":U.


RETURN (lwcp).

END FUNCTION.

/* Get the Class Path */
FUNCTION getData RETURNS CHARACTER ().
DEF VAR lcp AS CHARACTER.
LOAD "SYSTEM" BASE-KEY "HKEY_LOCAL_MACHINE".
USE "SYSTEM".

GET-KEY-VALUE SECTION "CurrentControlSet\Control\Session Manager\Environment"
KEY "CLASSPATH"
VALUE lcp.

UNLOAD "SYSTEM":U.


RETURN (lcp).
END FUNCTION.

/* Set the Class Path - Will not work on Windows 98*/
FUNCTION setData RETURNS LOGICAL (INPUT lcp AS CHARACTER).
DEF VAR is-ok AS LOGICAL.
LOAD "SYSTEM" BASE-KEY "HKEY_LOCAL_MACHINE" NO-ERROR.
IF ERROR-STATUS:ERROR THEN RETURN (NO).
USE "SYSTEM" NO-ERROR.
IF ERROR-STATUS:ERROR THEN RETURN (NO).
PUT-KEY-VALUE SECTION "CurrentControlSet\Control\Session Manager\Environment"
KEY "CLASSPATH"
VALUE lcp NO-ERROR.
IF ERROR-STATUS:ERROR THEN RETURN (NO).
UNLOAD "SYSTEM":U NO-ERROR.
IF ERROR-STATUS:ERROR THEN RETURN (NO).

RETURN (YES).
END FUNCTION.

wcpath = getwcpath().
classdata = getData().

/* debugging
DISPLAY classdata FORMAT "x(69)".
MESSAGE classdata VIEW-AS ALERT-BOX.
DISPLAY wcpath FORMAT "x(68)".
*/


IF classdata = "" OR classdata = ?
THEN classDATA = WCpath + "<insert directory>\o4glrt.zip".
ELSE IF LOOKUP(wcpath + "<insert directory&gt.;\o4glrt.zip",classdata,';') = 0
THEN classDATA = classDATA + ';' + WCpath + "<insert directory>\o4glrt.zip".


/* This is needed to set into the Registy for permenance */
IF setdata(classdata) THEN DO:
classdata = getData().
END.

ELSE MESSAGE "ERROR: Failed to Update the Registry".

/* This is needed to set the children */
RUN SetEnvironmentVariableA("CLASSPATH",classdata,OUTPUT iret).


set-size(cmd) = length("Environment") + 1.
put-string(cmd,1) = "Environment" + chr(0).

run SendMessageTimeoutA({&HWND_BROADCAST}, {&WM_SETTINGCHANGE}, 0,
GET-POINTER-VALUE(cmd), {&SMTO_ABORTIFHUNG},
5000, output wResult).


/* MESSAGE wresult iret OS-GETENV("CLASSPATH") view-as alert-box. */

/* This will work but the WebClient will not see the CLASSPATH */
OS-COMMAND "regsvr32 <path>\<proxy dll>".


This code will allow the WebClient to set the environment variable for child processes and allow it to register the proxy but a reboot may be necessary to fully cast the new environment to all other processes..