How to call an external dll

asimhg

New Member
Hi there,

I have written a C# program that would confirm if the logged in user is from a particular domain, and return true or false.

I want to run this from progress code and if the C# dll returns true, then I can continue with other processing, and if the C# dll returned false, then display a message to the user.

Please advise how can I accomplish this, or if there is way we could determine the logged on user's domain in Progress code, that would be great too.


Thanks,
Asim
 

rstanciu

Member
/*------------------------------------------------------------------------
File : gethostname.p
Purpose : Return hostname of local machine
Author(s) : Steve Southwell - BravePoint, Inc.
Created : 8/22/02
Copyright : 2002 - The FreeFrameWork Project, Inc. - Use according to FFW license
Notes : Thanks to Bill Prew (billprew@cox.net) for posting a
fine example of the Windows getHostName API at
http://www.global-shared.com/api/ip.html
Thanks to David Craven, Scott Ziola, and Hugh Cruickshank
for *nix input.
----------------------------------------------------------------------*/

DEFINE OUTPUT PARAMETER p-TcpName AS CHARACTER NO-UNDO.

&IF OPSYS = "UNIX" &THEN
&SCOPED-DEFINE SC STREAM cmdstream
DEFINE {&SC}.
INPUT {&SC} THROUGH VALUE("hostname -f"). /* if this doesn't work on your platform, try uname -n */
IMPORT {&SC} UNFORMATTED p-TcpName.
INPUT {&SC} CLOSE.

&ELSE
&SCOPED-DEFINE WSADATA_LENGTH 403
DEFINE VARIABLE w-TcpName AS CHARACTER NO-UNDO.
DEFINE VARIABLE w-Length AS INTEGER NO-UNDO.
DEFINE VARIABLE w-Return AS INTEGER NO-UNDO.
DEFINE VARIABLE ptr-WsaData AS MEMPTR NO-UNDO.

/* Initialize return values */
ASSIGN p-TcpName = ?.

/* Allocate work structure for WSADATA */
SET-SIZE(ptr-WsaData) = {&WSADATA_LENGTH}.

/* Ask Win32 for winsock usage */
RUN WSAStartup (INPUT 257, /* requested version 1.1 */
INPUT GET-POINTER-VALUE(ptr-WsaData),
OUTPUT w-Return).

/* Release allocated memory */
SET-SIZE(ptr-WsaData) = 0.

/* Check for errors */
IF w-Return NE 0 THEN DO:
ASSIGN p-TcpName = "".
RETURN.
END.

/* Set up variables */
ASSIGN w-Length = 100
w-TcpName = FILL(" ", w-Length)
.

/* Call Win32 routine to get host name */
RUN gethostname (OUTPUT w-TcpName,
INPUT w-Length,
OUTPUT w-Return).

/* Check for errors */
IF w-Return NE 0 THEN DO:
ASSIGN p-TcpName = "".
RUN WSACleanup (OUTPUT w-Return).
RETURN.
END.

/* Pass back gathered info */
/* remember: the string is null-terminated so there is a CHR(0)
inside w-TcpName. We have to trim it: */
p-TcpName = ENTRY(1,w-TcpName,CHR(0)).

/* Terminate winsock usage */
RUN WSACleanup (OUTPUT w-Return).



/* External Procedure Prototypes */

PROCEDURE gethostname EXTERNAL "wsock32.dll" :
DEFINE OUTPUT PARAMETER p-Hostname AS CHARACTER.
DEFINE INPUT PARAMETER p-Length AS LONG.
DEFINE RETURN PARAMETER p-Return AS LONG.
END PROCEDURE.

PROCEDURE WSAStartup EXTERNAL "wsock32.dll" :
DEFINE INPUT PARAMETER p-VersionReq AS SHORT.
DEFINE INPUT PARAMETER ptr-WsaData AS LONG.
DEFINE RETURN PARAMETER p-Return AS LONG.
END PROCEDURE.

PROCEDURE WSACleanup EXTERNAL "wsock32":
DEFINE RETURN PARAMETER p-Return AS LONG.
END PROCEDURE.

&ENDIF
 
Top