I made a "Connect" button in Borland C++ and I added the following code to the button.
void __fastcall TForm1::Button1Click(TObject *Sender)
{
WideString server_name = Edit1->Text;
MULTI_QI qi[1];
memset(qi,0,sizeof(qi));
COSERVERINFO server_info;
memset(&server_info,0,sizeof(server_info));
server_info.pwszName = server_name;
CoInitialize(NULL);
qi[0].pIID = &IID_IsingleObject;
HRESULT hr = CoCreateInstanceEx(CLSID_singleObject,
NULL,
CLSCTX_SERVER,
&server_info,
1,
qi);
this->server = NULL;
this->server = (IsingleObject*)qi[0].pItf;
ShowMessage(hr);
}
My QUESTION is how to ADD a method to my client, which takes care of connecting to the server
The prototype of this method is as follows:
// mind the return value.
HRESULT connect(WideString server_name);
After implementing this method, I’ll use this for the “connect”-button instead of the source code I got now.
void __fastcall TForm1::Button1Click(TObject *Sender)
{
WideString server_name = Edit1->Text;
MULTI_QI qi[1];
memset(qi,0,sizeof(qi));
COSERVERINFO server_info;
memset(&server_info,0,sizeof(server_info));
server_info.pwszName = server_name;
CoInitialize(NULL);
qi[0].pIID = &IID_IsingleObject;
HRESULT hr = CoCreateInstanceEx(CLSID_singleObject,
NULL,
CLSCTX_SERVER,
&server_info,
1,
qi);
this->server = NULL;
this->server = (IsingleObject*)qi[0].pItf;
ShowMessage(hr);
}
My QUESTION is how to ADD a method to my client, which takes care of connecting to the server
The prototype of this method is as follows:
// mind the return value.
HRESULT connect(WideString server_name);
After implementing this method, I’ll use this for the “connect”-button instead of the source code I got now.