Contents Previous Next Subchapters

Setting the Name of an OMDDE Server
Source Files: winmain.c omdde.c dderror.c omdde.h

Prototype
int OMServerRegister(char *name)
int OMServerUnregister()


OMServerRegister
A call to OMServerRegister enables future connections to applications that use the same value for name in a call to OMClientConnect . The argument name is a '\0' terminated character string specifying the name for this server. If this program made a previous call to OMServerRegister, you must first unregister it using the routine OMServerUnregister, otherwise this registration will fail. The return value is TRUE, if the registration is successful and FALSE otherwise.

OMServerUnregister
This call stops the current server.

Example
When linked with the program WinMain , the example below sets up a server called "C-server".

# include <stdio.h>
# include "define\omdde.h"

extern void AddText(char *add);

int OMServerCmd(char *cmd)
{    return FALSE;
}
int OMServerInput(enum type_mat mtype, int nr, int nc, void *data)
{    return FALSE;
}
void OMServerOutput(enum type_mat *mtype, int *nr, int *nc, void *data)
{    *mtype     = UNDEF_mat;
     return;
}

void Setup()
{    
     int    ok;

     AddText("Demo OMServerRegister\n");
     ok = OMDdeInitialize();
     if( ! ok )
     {    AddText("Cannot initialize OMDDE\n");
          return;
     }
     ok = OMServerRegister("C-Server");
     if( ! ok )
     {    AddText("Cannot register server\n");
          OMDdeUninitialize();
          return;
     }
}

void ShutDown()
{
     OMDdeUninitialize();
     return;
}

If you have the Microsoft Visual C++ compiler, you can compile and link this example by executing the command
     nmake /f windows.mak omserreg.exe
in the directory c:\omwin\omdde. If you then execute the command
     omserreg
then run a copy of O-Matrix, and at the O> prompt you enter
     omlink("client", "C-server")
O-Matrix will respond
     T
to signal that a connection has been established to the "C-server" server.