|
I use C/C++ in the executable COM and in the client.
|
|
|
|
|
If EXE server starts by COM system, his command line contains the "Embedding" keyword.
OTOH, you can specify the necessary keyword(s) in .rgs file under "LocalServer32" key. E.g.
LocalServer32 = s '%MODULE% -Automation'
With best wishes,
Vita
|
|
|
|
|
I want to pass a SafeArray to a VB Client but I can't seem to get the right syntax for the IDL.
Can someone please help me.
Forever Developing
|
|
|
|
|
[attributes] LPSAFEARRAY *varname
|
|
|
|
|
I should have been more clear.
I want to pass the SafeArray pointer out to VB 6 in ATL 3.0.
I used to be able to do this with the following code.
foo(SAFEARRAY(long) *psa);
However the same thing in ATL 7.0 won't compile
NOTE: I am using an emedded idl VS.NET
//Actual code
#define _ATL_ATTRIBUTES 1
#include "stdafx.h"
#include "resource.h"
#include "atlbase.h"
#include "atlcom.h"
#include "oleauto.h"
#include "atlsafe.h"
#include "oaidl.h"
// The module attribute causes DllMain, DllRegisterServer and DllUnregisterServer to be automatically implemented for you
[ module(dll,name="ATL7TEST")];
[object, dual, uuid(4D9BCA91-2F02-4cee-A589-2CC4D9821156)]
__interface IATL7TEST
{
HRESULT TestRaiseEvent();
};
[object,uuid("8D0F6D5E-DDC3-4371-BB08-49864F5DE356")]
__interface _IATL7EVENTS
{
HRESULT MyFirstEvent(SAFEARRAY(long*) *varname );
};
[coclass, uuid(EBAA6CB2-ED31-4e08-8DF8-068B2978C3F7),event_source(com)]
class TESTING :
public IATL7TEST
{
public:
__event __interface _IATL7EVENTS;
HRESULT TestRaiseEvent()
{
CComSafeArray<long> Test;
SAFEARRAY *psa;
SAFEARRAYBOUND rgsabound[1];
rgsabound[0].lLbound = 0;
rgsabound[0].cElements = 10;
psa = SafeArrayCreate(VT_INT, 1, rgsabound);
long test;
test = 1234;
LPSAFEARRAY lpsa;
lpsa = psa;
__raise MyFirstEvent(psa);
return S_OK;
}
};
//compilation errors
//v:\ATL7TEST\ATL7TEST.cpp(33): error C2061: syntax error : identifier 'tagSAFEARRAY'
//v:\ATL7TEST\ATL7TEST.cpp(33): error C2059: syntax error : ')'
//v:\ATL7TEST\ATL7TEST.cpp(33): error C2143: syntax error : missing ')' before ';'
Forever Developing
|
|
|
|
|
I am developing a COM dll that includes 3rd party dll in MFC 6.0. This 3rd party DLL reaches back into a java layer within itself via JNI(Java Native Interface). At my project level, I am getting
the following compile-time link time errors:
error LNK2001: unresolved external symbol "__declspec(dllimport) ?$S494@?1??IteratorClass@?$Iterator@VObservable@immaccs@@@util@@CAPAV_jclass@@XZ@4EA" (__imp_?$S494@?1??IteratorClass@?$Iterator@VObservable@immaccs@@@util@
@CAPAV_jclass@@XZ@4EA)
What is interesting is if I put the 3rd party stuff into a regular MFC exectuable project, the compile works fine. Projects are being compiled in release mode. Are there any known problems associated with a COM dll linking in another dll that has jni signatures in it?
Thank you for your time!
|
|
|
|
|
How do I connect to the interface of a component, without importing the type library (dont want to include header either) ? Is there anyway I can get the information from the registry, given the fact that I know the prototypes for the methods present in that interface ?
Basically, I want to access a new component without changing my client app. (Again, the new component's interface methods are known).
Thanks
<marquee>. . . Humans do it better . . .
|
|
|
|
|
Hello,
I'm an experienced programmer, but new to COM. I'd like to add a new option to the 'right-click' menu in internet explorer so rather than performing a 'save as' command I can send GIFs and JPEGs directly to an art program I've written. Is this possible? It seems possible, I just can't find the info I need.
thanks.
|
|
|
|
|
From Microsoft:
http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/hosting/wbcustomization.asp
|
|
|
|
|
I am trying to get access to DataGrid control placed on a Dialog box but without using MFC enviroment (since the code I have is designed this way), and I wondered why the ActiveX DataGrid placed on a Dialog breaks in the callback where WM_INITDIALOG is never called. I needed this because it is the only way I know of to then initialize the DataGrid control with my recordset object.
Any pointers or suggestions?
Thanks--
|
|
|
|
|
I have a task to do: I need to add virtual drive to the system that will display some virtual folders and files. Can somebody help me to start - how to create virtual drive?
Thank you in advance
Stas
|
|
|
|
|
I'm writing a com component that has two interfaces that derive from IDispatch. When I compiled the project I got the error:
error C2594: 'static_cast' : ambiguous conversions from 'class CExplorerBar *' to 'struct IDispatch *'. So I changed the COM_INTERFACE_ENTRY to COM_INTERFACE_ENTRY2, so I could specify the IDispatch. Now I have 1 error and 3 warning (I'll just post the error):
c:\program files\microsoft visual studio\vc98\atl\include\atlcom.h(1827) : error C2259: 'CComObject<class cexplorerbar="">' : cannot instantiate abstract class due to following members:
c:\program files\microsoft visual studio\vc98\atl\include\atlcom.h(1823) : while compiling class-template member function 'long __stdcall ATL::CComCreator<class atl::ccomobject<class="" cexplorerbar=""> >::CreateInstance(void *,const struct _GUID
&,void ** )'.
Any ideas about what's going on?
Thanks.
Melinda.
|
|
|
|
|
You cannot inherit from two interfaces derived from IDispatch, because the IDispatch is not a virtual base class ( as the error message is saying, the compiler cannot decide which base class to consider for casting).You can disambiguate the cast by specifying which base class to consider ( (IDispatch*)(IInterface1*)this).
Another issue is that you will have DISPID clashes from the two interfaces ( id 1 assigned to method "test" in iface 1, and for method "clone" for iface2). The solution is dispid encoding ( you can find an article on codeguru about this), manually implementing IDispatch or using tear-off objects.
|
|
|
|
|
Hi All,
How do we handle dual LAN in DCOM.
Suppose I have two machines which are connected to two networks say network A & network B. Each machine has two IP addresses.
My Server is running on one machine & Client on another.
First of all when my Client makes a call to connect to the Server through which network will it get connected ? A or B ?
Moreover suppose the connection was established through network A. Now I want that when someone pulls out the network A LAN cable from Client's or Server's machine then the Client automatically gets connected to the Server through netwrok B.
Does DCOM has a solution for this ?
Please note that the Networks cards installed in the machines are normal cards. They do not form a team.
Best Regards,
Deepak
|
|
|
|
|
You get to decide to which machine the client will connect, by specifying the remote server name in COSERVERINFO structure when calling CoCreateInstanceEx ( or by setting the appropriate value for RemoveServerName into the registry for the server component). DCOM does not have such failsafe mechanisms - if you cannot use the primary server anymore try to switch to the other one.
|
|
|
|
|
Hi All,
How do we handle dual LAN in DCOM.
Suppose I have two machines which are connected to two networks say network A & network B. Each machine has two IP addresses.
My Server is running on one machine & Client on another.
First of all when my Client makes a call to connect to the Server through which network will it get connected ? A or B ?
Moreover suppose the connection was established through network A. Now I want that when someone pulls out the network A LAN cable from Client's or Server's machine then the Client automatically gets connected to the Server through netwrok B.
Does DCOM has a solution for this ?
Please note that the Networks cards installed in the machines are normal cards. They do not form a team.
Best Regards,
Deepak
|
|
|
|
|
Hi all,
I have the following code called from a worker thread in a DLL
HRESULT hRes = CoCreateInstance(CLSID_ToPickReg1,NULL,CLSCTX_INPROC_SERVER,__uuidof(IMyInterface),(void**)&m_pRegInterface);
and then I issue a call to a function like this
hRes = ((IMyInterface*)m_pRegInterface)->GetBinDir(&pChar,&errorCode);
where pChar is of type unsigned int * and the function signture is
CMyInterface::GetBinDir(unsigned char **ppuchBinDir, long *plErrorCode)
What I am getting is error 1783 or "The stub received bad data" in Win98 first edition with or without DCom98 installed, while in Win2000 everything works like a peach.
Any ideas?
Thanks in advance.
Alberto Gattegno
Software Engineer
http://www.itgil.com
|
|
|
|
|
This is more Word related than COM related, so I hope you don't mind me asking...
I am using automation of MS Word to build a Word document, and would like to add footers which contain the page number, in the format [some text] [page number] [some text].
It seems to be that you can set the text of the header and footer using HeaderFooter::GetRange() and then Range::SetText(), and you can add a page number to the footer using HeaderFooter::GetPageNumbers() and then PageNumbers::Add() , but you can't marry up the text and page number.
Any ideas on how I can tackle this. Alternatively, does anyone know of any good books that cover word automation to this sort of depth?
Thanks in advance!
|
|
|
|
|
Have actually found the solution now (not ten minutes after asking ), but thought I would post the solution as opposed to deleting the thread, in case anyone else had the same problem
Instead of adding to the PageNumbers collection, all you need to do is add a field of type wdFieldPage to the header / footer range. Simple really
|
|
|
|
|
I want to use my exe-server (attributed) in a MFC-application with several threads. In the main thread of the MFC-application I use smartpointers and CreateInstance to create an instance of the exe-server. By using CoInitializeEx(NULL, COINIT_MULTITHREADED) I get access to the server in every thread of my application. By using CoInitialize(NULL) just the main thread has access to the server, but that's clear. My Problem is, that if I use any ActiveX component in the application the threading model seems to be initialized automaticaly for single threading and calling CoInitialize is not possible anymore.
Is there a solution for my problem ?
|
|
|
|
|
The apartment is initialized for each thread once when you call CoInitInstance ( Ex). If you use COINIT_MULTITHREADED, you can pass around the interface ptr without any problems in any thread marked as MTA. Between threads with different apartments you must marshall the interface ( you can use CoMarshalInterThreadInterfaceInStream / CoGetInterfaceAndReleaseStream)
|
|
|
|
|
hello,
i try to create com objects which can be used by scripting clients and by c++ clients
very easily. this is no problem with the objects itself. but i have some trouble with
the events.
if i create the source interface as a standard interface based on idispatch the
wscript.exe crashes. if i look at the event proxy class generated by msvc, i see that
the methods on the interface are called directly, i think this will not work on script
clients. so i changed the interface to a dispinterface, now the generated proxy class
calls the method via invoke, scripting client works fine. but if i want to receive this
event in a simple c++ app the methods are not called directly, well, of course the
invoke method is called instead. so it is not so easy usable in c++. therefore i always
implement two source interfaces per object, on dispinterface as [default,source] for
script clients, and another iunknown based interface with the same methods as [source]
for c++ clients. this works fine, although it is more work to do. i do not know, if
there is a better way to support idispatch clients via invoke, and vtable clients directly
via the method calls? i thought maybe i can qi the interface connected to the cp, and
the idispatch connection will only return the idispatch interface, but it also returns
the event interface without error, but the method call fails.
second problem is that i do not get the automagic in wscript running. the event handler
is called the right way, but it is not executed. i always have to use the
WScript.ConnectObject obj, "obj_" method to connect to the events, then it is working
with vbscript. any idea why? do i need to support additional interfaces for the automagic
support? i added the IProvideClassInfo2Impl and IObjectWithSiteImpl to get the connect-
object method working.
and i have no idea how to use the events in a html-page with jscript. i do not get the
automagic working there, too, maybe the same problem. and attaching a function directly
to an event, like obj.event = myeventfunc, does not work, i always get the error, that
the object does not support the method or property. does it make any problems that the
event has parameters? the sample for onload, onclick do not have parameters. or is something
like the wscript.connectobject available for jscript and html?
well, that all for now, i hope someone could answer one or another? would be great.
many thanks in advance
enrico
|
|
|
|
|
I would like to offer the following decision.
[
oleautomation,
uuid(XXXXXXXX-XXXX-...),
helpstring("...")
]
interface ISomeEvents : IDispatch
{
[id(SomeDispid),helpstring("...")] HRESULT OnSomeEvent();
...
};
[
uuid(XXXXXXXX-XXXX-...), version(n.m), helpstring("...")
]
library SomeLib
{
...
[
uuid(XXXXXXXX-XXXX-...), helpstring("...")
]
coclass SomeCoClass
{
[default] interface ISome;
[default, source] interface ISomeEvents;
};
};
The sink of this interface can be implemented by ATL::IDispatchImpl instead of ATL::IDispEventImpl or ATL::IDispEventSimpleImpl.
With best wishes,
Vita
|
|
|
|
|
hello,
well, i tried this, but the result is almost the same. the msvc wizard creates a proxy class
with direct calls to the functions instead of the invoke, therefore the wscript crashes.
what i the idea of not using the dual? could you explain this? why use dual, why not?
enrico
|
|
|
|
|
I think that you should correct the Wizard to indirect call to the functions. Server must made a call only by Invoke. It's a script requirement.
But your C++ client can realize the sink more simply.
VB, VBS and all ole-automation clients will use the dispatch's Invoke.
But C++ clients can use ATL::IDispatchImpl class (with TLB inforamtion, but without BEGIN_SINK_MAP) instead of ATL::IDispEventImpl class (with manual BEGIN_SINK_MAP), which has also some bugs within it.
HTH
With best wishes,
Vita
|
|
|
|