API is not working properly

Posted by Admin on 17-Dec-2007 03:43

Hi,

I have a problem i.e. related to mapped drive.

I am using the following code to check whether a particular drive is mapped or not.

/* code start */
DEFINE VARIABLE Drive_Name AS CHARACTER NO-UNDO INIT "Z:".
DEFINE VARIABLE UNC_Name AS CHARACTER NO-UNDO.

DEFINE VARIABLE namelen AS INTEGER NO-UNDO INITIAL 100.
DEFINE VARIABLE retBool AS INTEGER NO-UNDO.

UNC_Name = FILL("x",namelen).
RUN WNetGetConnectionA ( Drive_Name,
OUTPUT UNC_Name,
INPUT-OUTPUT namelen,
OUTPUT retBool).


IF retBool = 0 THEN

MESSAGE SUBSTRING(UNC_Name, 1, namelen)
VIEW-AS ALERT-BOX INFO BUTTONS OK.

ELSE

MESSAGE "Not Mapped"
VIEW-AS ALERT-BOX INFO BUTTONS OK.


PROCEDURE WNetGetConnectionA EXTERNAL "mpr.dll" :
DEFINE INPUT PARAMETER lpDrive AS CHARACTER.
DEFINE OUTPUT PARAMETER lpUNCName AS CHARACTER.
DEFINE INPUT-OUTPUT PARAMETER lpnLength AS LONG.
DEFINE RETURN PARAMETER RetBool AS LONG.
END PROCEDURE.

/* code end */

When i run this code in procedure editor, it is working perfectly and gives the correct result.

But when embed the same program is speed script and make necessary changes, then it gives me wrong result. I am doing the following chages i.e change message statement with {&OUT} statement.

If anybody know(s) about the solution, please help me.

Thanks in advance,

Ramesh

All Replies

Posted by kevin_saunders on 18-Dec-2007 02:46

I suspect the issue is that the AdminServer (and thus the WebSpeed Broker) is started using the 'System' account in Windows Services. The system account has no rights to the network, which is why it works in the procedure editor (running under your login) but not in Webspeed.

Change the AdminServer to start as a real user rather than System and it should work just fine.

This thread is closed