Sam Trenholme's webpage
This article was posted to the Usenet group alt.hackers in 1995; any technical information is probably outdated.

Making 2 programs communicate


Article: 7595 of alt.hackers
From: eeittn@eei.ericsson.se (Tony Tehan )
Newsgroups: alt.hackers
Subject: Making 2 programs communicate
Date: 4 Apr 1995 14:18:34 GMT
Organization: Ericsson Systems Expertise Ireland
Lines: 72
Approved: Anto
Distribution: world
Message-ID: 3lrkfq$3ft@erinews.ericsson.se
Reply-To: eeittn@eei.ericsson.se
NNTP-Posting-Host: eeibhuc37.eei.ericsson.se
Status: RO


Hi Folks,

This is my first post to this group.
Anyone want to explain what the OB in OBHack is for.
I guess it means obligatory.

Anyway here is my hack which at the time I thought was
quite clever.

In my previous job I was asked to write a program that
provided a nice GUI type interface for low level RS232
type communications with a PABX (telephone system).  Now
as usual in the commercial this was wanted quickly.

The requirement was that the program was easy to use and
could run on an 8086 based PC.

Now the company had bought Visual Basic (Microsoft),
MASM (microsoft) and Turbo C++ (Borland).

Given the time constraint, VB was the best bet for the
user interface.  I recommend it since it can produce
very professional looking user interfaces very quickly,
although the code it produces is far from compact or
efficient.

The low level communications I needed to perform were not
true RS232 and required lots of nice low level programming.
Therefore for this C with liberal doses of assembly was
ideal.

There was no problem linking the C to the assembly or
the Visual Basic to the assembly.  However since the
C and Visual Basic were from different manufacturers,
I couldn't persuade the 2 to link.

After much effort to try and link the 2 I came up with the
following solution.

The C program ran and then terminated and stayed
resident.  It also hooked interrupt 60H.

The VB program was then run and included a function similar
to:
CALL DO_INTERFACE(FUNCTION_NUMBER,data1,data2,...)

This subroutine called an assembly program which took the
FUNCTION_NUMBER and the data and stored it in a data buffer.
The pointer to this buffer was put into 2 registers.

Then INT 60H was called.

The C interrupt handler took the registers and transferred
them to a C pointer.  Then the data was taken from the
buffer and put into C variables.

The FUNCTION_NUMBER was then used to decide which C
function to call.

Once the C and VB could agree on the FUNCTION_NUMBER
(done with include files) there was no problem getting
the VB to call any of my C functions.

It is a bit like INT 21H in DOS.

Tony.

P.S.  Not as difficult as I expected to find out how
to post to this group!





Back to index