View Single Post
Old 06-20-2003, 05:29 AM  
darkone
Disabled
 
darkone's Avatar
 
Join Date: Dec 2001
Posts: 2,230
Default

Since the other DDE thread was closed, I'll bring this oldie back up.

My suggestion is to use shared memory + window messages. It's very robust method and quite easy to implement. In C, I would do
it like this.. I could write a library (DLL) in C for this, but then again.. I think it shouldn't be too difficult to do with Delphi.

Btw. Shared memory is only available with WIN2K/XP/NET.

typedef struct _SERVER
{

CHAR HostName[MAX_HOSTNAME];
DWORD dwPort;
CHAR Login[MAX_USERNAME];
CHAR Password[MAX_PASSWORD];
HANDLE hEvent; // Event to set when socket status changes
DWORD dwStatusStore;

} SERVER, * PSERVER;


case WM_CONNECT:
// Lock shared memory
if (! (lpMemory = SHM_Lock(lParam, wParam))) break;
// Allocate temporary store
pServer = (PSERVER)HeapAlloc(hProcHeap, sizeof(SERVER));
// Check allocation
if (pServer)
{
// Expect memory to contain server info
CopyMemory(pServer, lpMemory, sizeof(PSERVER));
// Connect, and store id of status container
dwStatusStore = Connect(pServer);
// Swap pointer
pServer = (PSERVER)lpMemory;
// Store status
pServer->dwStatusStore = dwStatusStore;
}
// Unlock shared memory
SHM_Unlock(lpMemory);
break;

case WM_STATUS:
// Return connection status
return StatusArray[lParam];
darkone is offline