1SCDLL.DLL Coding info

1SCDLL.DLL Coding info

Postby Rudi De Vos » 2007-03-18 17:41

1SCDLL.def
Code: Select all
LIBRARY 1SCDLL
EXPORTS
    Start_server @1
    Stop_server @2

1SCDLL.h
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();


Import VC++
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);
}


Messages
(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);
            }


CLASSNAME_CHAR
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:
Rudi De Vos
Admin & Developer
Admin & Developer
 
Posts: 5793
Joined: 2004-04-23 10:21

Re: Coding info / other

Postby RainerK » 2008-02-11 14:44

Is it possible to receive the WM_APP+10 .. 14 to change a led?
(Msg WM_APP1 .. 5 is incoming)
RainerK
 
Posts: 4
Joined: 2007-03-02 18:52

Re: 1SCDLL.DLL Coding info

Postby SilentButeo2 » 2009-04-27 14:09

Rudi,

I think my question is the same a that from RainerK, but i'm not sure.

Is it possible to receive the messages (logging, led(WM_APP+10,11,12,13,14), ...) from the SCDLL?
I'd like to capture the logging from the SCDLL to another window, but i can't find how to do it.
Is there any info on how the SCDLL sends messages to the IDD_DIALOG1?

In the code is see that:

1. the server is started
2. the "PcHelpWare Info" window (IDD_DIALOG1) is created.

If I first create the window and then start the server, the logging form the SCDLL is not seen anymore in the IDC_LIST1. So i can't see how the SCDLL sends its messages to that window. Any info about this would be great.

So basically it comes to:
How can i tell the SCDLL to send the messages to my window instead of the IDD_DIALOG1?

Keep up the good work. The software you are brewing is fantastic.

Kind regards,
SilentButeo2
SilentButeo2
 
Posts: 2
Joined: 2009-04-27 13:47

Re: 1SCDLL.DLL Coding info

Postby Rudi De Vos » 2009-04-27 19:07

Not possible, no findwindow was used insite the dll.

Insite DLL

Code: Select all
g_hWnd_serv=CreateWindow(
         szWindowClass_serv,/* Pointer to registered class name */
         szTitle_serv,/* Pointer to window name */
         WS_OVERLAPPEDWINDOW,/* Window style */
         CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
         NULL,/* Handle to parent or owner window */
         NULL,/* Handle to menu or child-window identifier */
         g_hInstance_serv,/* Handle to application instance */
         NULL);/* Pointer to window-creation data */


Code: Select all
EditControl=CreateWindow ("EDIT", NULL,        WS_CHILD|WS_VISIBLE|WS_HSCROLL|WS_VSCROLL|ES_MULTILINE|ES_READONLY,0, 0, 0, 0, g_hWnd_serv, NULL, g_hInstance_serv, NULL);

//Logging is like this
SetWindowText(EditControl, txt);
Rudi De Vos
Admin & Developer
Admin & Developer
 
Posts: 5793
Joined: 2004-04-23 10:21

Re: 1SCDLL.DLL Coding info

Postby SilentButeo2 » 2009-04-28 14:21

Strange,

I can't figuring out how it is now working. Why is the logging printed in the "PcHelpWare Info" dialog? Can you explane this to me?

Secondly, is there maybe a special thrick in Start_my_server() that causes the window to "receive" the messages? Because the WM_SYSCOMMAND 's in DialogProc2() are send by the DLL and received by "PcHelpWare Info". So i think these messages can maybe received by another window?

Thanks Rudi
SilentButeo2
 
Posts: 2
Joined: 2009-04-27 13:47


Return to PcHelpWare

Who is online

Users browsing this forum: No registered users and 3 guests