|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
From: Murat Emrah Özdemir (muratemrah
HOTMAIL.COM)Date: Wed May 22 2002 - 12:53:06 CDT
I hope this will the last question.
There is a lot type of monikers, File Moniker, Class Moniker, Pointer
Moniker... Which is best for me??
I try to use Pointer moniker, but I couldn't be able to receive COM Object
pointer...
Here is the code, what is the wrong??
// Now we will initialize COM
HRESULT hr = CoInitialize(0);
if(SUCCEEDED(hr))
{
IMoniker* pMoniker=NULL;
IUnknown* pUnkForDataChange=NULL;
if( SUCCEEDED( CreatePointerMoniker(pUnkForDataChange, &pMoniker) )
&& pMoniker!=NULL )
{
IBindCtx* pBindCtx=NULL;
if(SUCCEEDED(CreateBindCtx(0, &pBindCtx)))
{
BIND_OPTS2 bindOpts2;
memset(&bindOpts2, 0, sizeof(bindOpts2));
bindOpts2.cbStruct = sizeof(BIND_OPTS2);
bindOpts2.grfFlags = 0; // Don't need
bindOpts2.grfMode = STGM_READWRITE; // should be unchanged
bindOpts2.dwTickCountDeadline = 0; // no deadline
bindOpts2.dwTrackFlags = 0; // Not relevant
BOOL bLocal=TRUE;
if (bLocal)
{
bindOpts2.dwClassContext = CLSCTX_LOCAL_SERVER;
bindOpts2.pServerInfo = NULL; // Not relevant as we
are local
}
else
{
/* WCHAR wsz [MAX_PATH];
char szRemoteMachine[80];
wsprintf(szRemoteMachine,"\\\\%s",lpszMachineName);
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED,
szRemoteMachine, -1,wsz, MAX_PATH);*/
COSERVERINFO si;
// Plug in the host name
memset(&si, 0, sizeof(COSERVERINFO));
//si.pwszName = wsz;
bindOpts2.dwClassContext = CLSCTX_REMOTE_SERVER;
bindOpts2.pServerInfo = &si; // describes remote
machine
}
bindOpts2.locale = GetUserDefaultLCID();
hr = pBindCtx->SetBindOptions(&bindOpts2);
if (FAILED(hr))
{
TRACE(TEXT("SetBindOptions failed with error %x\n"),
hr);
}
//IMMDataChange is desired Interface
IMMDataChange *pMMDataChange=NULL;
//This Function FAILED...
hr=pMoniker->BindToObject(pBindCtx, NULL,
IID_IMMDataChange, (void**) &pMMDataChange);
//hr=0x8000FFFF and pMMDataChange is remain NULL,
}
}
}
----- Original Message -----
From: "Sorin Rojea" <SorinR
IQ-L.COM>
To: <DCOM
DISCUSS.MICROSOFT.COM>
Sent: Wednesday, May 22, 2002 6:07 PM
Subject: Re: Accessing ROT of a Remote Machine
That's true.
Sorin Rojea,
Senior Software Developer,
http://www.iq-l.com
-----Original Message-----
From: Murat Emrah Özdemir [mailto:muratemrah
HOTMAIL.COM]
Sent: Wednesday, May 22, 2002 12:03 PM
To: DCOM
DISCUSS.MICROSOFT.COM
Subject: Re: Accessing ROT of a Remote Machine
So, My object is alreadey Registerd in ROT, as a result I should connect
to
server without changing any code in my server... Is it True??
----- Original Message -----
From: "Sorin Rojea" <SorinR
IQ-L.COM>
To: <DCOM
DISCUSS.MICROSOFT.COM>
Sent: Wednesday, May 22, 2002 5:54 PM
Subject: Re: Accessing ROT of a Remote Machine
The ROT enables a moniker to check whether an object is already running
when the client application calls the BindToObject method to bind to the
object. That's why the ROT acts mainly as a binding optimization to help
you avoid unnecessarily instantiating a new object when binding.
So if you want to use ROT then yes, you have to register your object in
the ROT using RegisterActiveObject.
If you are unfamiliar with ROT just do a search in MSDN for word "ROT"
and you'll get a bunch of articles and examples what to do.
Hope this helps.
Sorin Rojea,
Senior Software Developer,
http://www.iq-l.com
-----Original Message-----
From: Murat Emrah Özdemir [mailto:muratemrah
HOTMAIL.COM]
Sent: Wednesday, May 22, 2002 11:05 AM
To: DCOM
DISCUSS.MICROSOFT.COM
Subject: Re: Accessing ROT of a Remote Machine
Thank you for your answer...
But I have one more question..
What should I do on the server side?? Is it enough
::RegisterActiveObject(...)?? Should I create a moniker with
CReatePointerMoniker??
Thanks....
----- Original Message -----
From: "Sorin Rojea" <SorinR
IQ-L.COM>
To: <DCOM
DISCUSS.MICROSOFT.COM>
Sent: Wednesday, May 22, 2002 4:51 PM
Subject: Re: Accessing ROT of a Remote Machine
I just answered couple of days ago to this question on the ATL
discussion list.
Here is the answer
"Use the COSERVERINFO structure to specify the servername , from
BIND_OPTS2 structure when you do SetBindOptions member of the bind
context interface IBindCtx.
For a complete example look for "Bind to an object on a remote machine
using ROT" in MSDN."
Sorin Rojea,
Senior Software Developer,
http://www.iq-l.com
Sorin Rojea,
Senior Software Developer,
http://www.iq-l.com
-----Original Message-----
From: Murat Emrah Özdemir [mailto:muratemrah
HOTMAIL.COM]
Sent: Wednesday, May 22, 2002 10:42 AM
To: DCOM
DISCUSS.MICROSOFT.COM
Subject: Accessing ROT of a Remote Machine
Hello...
How can I connect client to the server (which is on remote machine).
My COM object is Singleton, and it is registered into Runnig Object
Table. I can easily connect the client to the server with using
GetActiveObject method. But As far as I know GetActiveObject couldn't be
use on a remote machine. I try to find some document, I should use
monikers for this purpose.
I couldn't find enough document about file monikers. I will be gratefull
if someone send me document, or sample code...
Thanks...
Murat Emrah Oezdemir
I&S IT PS 33 Erl - IT Plant Solutions
PCS & HMI Integrated Solutions
Fax:+49 9131 744481
GSM:+49 174 8400314
Email: mailto:murat.oezdemir
erl8.siemens.de
Siemens AG, Werner v. Siemens Str. 60, 91052 Erlangen
----------------------------------------------------------------
Users Guide http://discuss.microsoft.com/archives/mailfaq.asp
contains important info. Save time, search the archives at
http://discuss.microsoft.com/archives/index.html .
To unsubscribe, mailto:DCOM-signoff-request
DISCUSS.MICROSOFT.COM
----------------------------------------------------------------
Users Guide http://discuss.microsoft.com/archives/mailfaq.asp
contains important info. Save time, search the archives at
http://discuss.microsoft.com/archives/index.html .
To unsubscribe, mailto:DCOM-signoff-request
DISCUSS.MICROSOFT.COM
----------------------------------------------------------------
Users Guide http://discuss.microsoft.com/archives/mailfaq.asp
contains important info. Save time, search the archives at
http://discuss.microsoft.com/archives/index.html .
To unsubscribe, mailto:DCOM-signoff-request
DISCUSS.MICROSOFT.COM
----------------------------------------------------------------
Users Guide http://discuss.microsoft.com/archives/mailfaq.asp
contains important info. Save time, search the archives at
http://discuss.microsoft.com/archives/index.html .
To unsubscribe, mailto:DCOM-signoff-request
DISCUSS.MICROSOFT.COM
----------------------------------------------------------------
Users Guide http://discuss.microsoft.com/archives/mailfaq.asp
contains important info. Save time, search the archives at
http://discuss.microsoft.com/archives/index.html .
To unsubscribe, mailto:DCOM-signoff-request
DISCUSS.MICROSOFT.COM
----------------------------------------------------------------
Users Guide http://discuss.microsoft.com/archives/mailfaq.asp
contains important info. Save time, search the archives at
http://discuss.microsoft.com/archives/index.html .
To unsubscribe, mailto:DCOM-signoff-request
DISCUSS.MICROSOFT.COM
----------------------------------------------------------------
Users Guide http://discuss.microsoft.com/archives/mailfaq.asp
contains important info. Save time, search the archives at
http://discuss.microsoft.com/archives/index.html .
To unsubscribe, mailto:DCOM-signoff-request
DISCUSS.MICROSOFT.COM
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]