Hi, I am new here..
I faced a problem when I tried to call two difference software function..
I name this two software as App A and App B..
I had create App B's pointer at App A, name as BPointerAtA..
I try to new the pointer at App A ( BPointerAtA = new CBApp; )..
when I compile, a error occur..

--------------------Configuration: A - Win32 Debug--------------------
Linking...
ADoc.obj : error LNK2001: unresolved external symbol "public: __thiscall CBDlg::CBDlg(class CADoc *,class CWnd *)" (??0CBDlg@@QAE@PAVCADoc@@PAVCWnd@@@Z)
A.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

A.exe - 2 error(s), 0 warning(s)

in this two software, do not have any .lib file for me to do the setting..
i had tried before that at Project ->Settings->Linker, i keyin BDlg.obj inside..
after compile, it have more linking error that now..

anything i need to do to solve this error..??
or calling two difference software each other functions is illegal, even though both are writen in Visual C++ 6.0..??

anyway..
thank you..

regards,
shizu

I think you'd be better off trying to separate the common stuff that both apps use into a dll and then having both apps reference the dll. What exactly do you need to do this for anyway?

thank you for replying..

I using two software because one of them is control motor movement and another one is do the inspection..

I would like to separate this two software because it is easier to troubleshoot once have control error occur..

I do not want to use Comm Port, IO Signal or Text File to communicate within each other software because these method will take time..
although it may only use 10 or 20 mili seconds, but it will take quite much effect on my machine running..

but if this two software can call each other function using pointer, then it can solve my timing problem..

I tried before other method like calling each Com to communicate..
App A's Com name as ComA, and App B's Com name as ComB..
I tried use App A to call ComB and App B to call ComA..
It's work..but i found out that address is different..
for example .. :
App A call ComB..ComB address is 0x0123456..at the same time,
App B call ComB..ComB address is 0x0987654..
it mean that when I pass value to ComB using App A and display at App B..
App B will display default value ..not the value that App A pass to..
it is cause by the different address..

do you have any idea can help me out..??
or do you have any idea suggest to me so that my two software can call each other functions..??

thank you anyway to answer my question..

regards,
shizu

Hi, according the webpage that previous mail, i think that SendMessage() command will help me up..but i don't know how to use this command..
i think that i need to new a pointer which is the problem that i face now..
i would like to call this sendmessage command at App A..and call to App B..like below..
At App A..
App B->SendMessage(UWM_MSG);
At App B..
LRESULT CBApp::MSG(WPARAM wParam, LPARAM lParam)
{
...
}

but i don't have AppB's pointer..
if i NEW it, then this pointer will different with the pointer that i currently use it AppB..
because this two App have .exe..

am i have a wrong concept abt SendMessage()'s command..??
actually i do not know how it use, i use it just like i call PostMessage() command..

pls help..
thank you..
shizu

use :: SendMessage to a window of application B. and you *must* use a WM_COPYDATA message. eg.

// ...
HWND window = ::FindWindow( 0, L"app B's window title" ) ;
if( IsWindow(window) )
{
     
     TCHAR message[] = L"Hello World" ;
     COPYDATASTRUCT data = { 0, sizeof(message), message } ;
     ::SendMessage( window, WM_COPYDATA, 0 /* your window's handle */, &data ) ;
}

Thank's for replying..
I try to use coding just like you attached here, but after compile have error..

void CADlg::OnCancel()
{
// TODO: Add extra cleanup here
TCHAR name[] = "app B's window title";
HWND window = ::FindWindow( 0, name ) ;
if( IsWindow(window) )
{
TCHAR message[] = "Hello World" ;
COPYDATASTRUCT data = { 0, sizeof(message), message } ;
:: SendMessage( window, WM_COPYDATA, 0 /* your window's
handle */, &data ) ;
}
}


error msg is:..
--------------------Configuration: a - Win32 Debug--------------------
Compiling...
aDlg.cpp
C:\a\aDlg.cpp(183) : error C2664: 'SendMessageA' : cannot convert parameter 4 from 'struct tagCOPYDATASTRUCT *' to 'long'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
Error executing cl.exe.


a.exe - 1 error(s), 0 warning(s)

may i know why this error will appear..
how to solve it..??
I tried convert it into long, but still fail..
software that i use is VC6++..

thank you..
shizu

Hi, the above error i already solve..
thanks ..

After I call the :: SendMessage's function from App A, nothing effect from App B..
what command or function I need to add to get the data that send from App A..??

pls advise..
thank you..
shizu

sending data:

// ...
HWND window = ::FindWindow( 0, L"app B's window title" ) ;
if( ::IsWindow(window) )
{
     TCHAR message[] = L"Hello World" ;
     COPYDATASTRUCT data = { 0, sizeof(message), message } ;
     ::SendMessage( window, WM_COPYDATA,
                    WPARAM( 0 /* your window's handle */ ),
                    LPARAM( &data ) ) ;
}
//...

receiving data:
from your code it appears that you are using MFC;
a. in your CMainFrame (the top window) class (mainfrm.h) add,

class CMainFrame : public CFrameWnd
{
  // ...
    afx_msg LRESULT OnCopyData(WPARAM, LPARAM); // *** add this ***
  // ...
};

b. in mainfrm.cpp, add a mesage map entry

BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  // ... other message map entries
  ON_MESSAGE( WM_COPYDATA, OnCopyData ) // *** add this ***
END_MESSAGE_MAP()

c. in mainfrm.cpp, implement the message handler

LRESULT CMainFrame::OnCopyData( WPARAM wParam, LPARAM lParam )
{
  COPYDATASTRUCT* pcds = (COPYDATASTRUCT*)lParam ;
  // use the data
  // eg.
  ::AfxMessageBox( LPCTSTR(pcds->lpData) ) ;
  // if you want to keep the data for later use, you must
  // allocate memory yourself and do a deep copy of the data
  // ...
  return 0 ;
}

Thank you very much..
It solve my problem..
thanks again..

regards,
shizu

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.