Code: Select all
LIBRARY 1SCDLL
EXPORTS
Start_server @1
Stop_server @2
Code: Select all
#ifdef MY1SCDLL_EXPORTS
#define MY1SCDLL_API __declspec(dllexport)
#else
#define MY1SCDLL_API __declspec(dllimport)
#endif
MY1SCDLL_API void Start_server(char *ID, char *repeater,char *direct,int port,char *passwd,bool proxy,char *classname,bool have_to_wait);
MY1SCDLL_API void Stop_server();
Code: Select all
typedef void ( *Start_server_fn)(char *,char *,char *,int,char *,bool,char *,bool);
typedef void ( *Stop_server_fn)(void);
Start_server_fn Start_server=NULL;
Stop_server_fn Stop_server=NULL;
HMODULE hDLL=NULL;
bool
ImportDLL_functions()
{
hDLL = LoadLibrary ("1SCDLL.dll");
if (!hDLL) return 0;
Start_server = (Start_server_fn) GetProcAddress(hDLL,"Start_server");
Stop_server = (Stop_server_fn) GetProcAddress(hDLL,"Stop_server");
if (!Start_server || !Stop_server)
{
// handle the error
FreeLibrary(hDLL);
return 0;
}
return 1;
}
void
Free_DLL_functions()
{
if (hDLL)
FreeLibrary(hDLL);
}
(dll -> application)
// WM_APP+1 disconnect
// WM_APP+2 waiting viewer
// WM_APP+3 connected
// WM_APP+4 disconnecting
// WM_APP+5 user press exit in tray
Dll code used to send message
Code: Select all
HWND temphwnd=FindWindow(CLASSNAME_CHAR,NULL);
if (temphwnd)
{
SendMessage(temphwnd,WM_SYSCOMMAND,WM_APP+5,0);
}
Start_server(char *ID, char *repeater,char *direct,int port,char *passwd,bool proxy,char *classname,bool have_to_wait);
Your application need to receive the message in winproc
Code: Select all
BOOL CALLBACK WinProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
case WM_SYSCOMMAND:
switch (LOWORD(wParam))
{
case WM_APP+1: