How CallService is defined in IDL file? If it's "CallService([in] VARIANT *p1)", then you cannot change the parameter. If it's "CallService([in,out] VARIANT *p1), then you cannot receive the parameter in Integer.
IAC, VB passes myInt variable as VT_BYREF | VT_I2 to be possible to change the myInt value. It's made only during call some method. Inside VB don't store variant by this manner.
And yes, now I understand, as I suspected, I can't reallocate the VT_BYREF | VT_I2 inside my ATL code.
The only thing still not 100% clear which confused me is that I can define a VB procedure receiving a byref variant, do the same thing receiving my int, and changing it to String and no leak happens. That was my first test.
But the difference is: there's no COM in this scenario, and the pure VB allocation\dellocation mechanisms are not the same.
STDMETHODIMP CDCSClient::CallService(/*[in,out]*/ VARIANT *p)
if (V_VT(p) == (VT_VARIANT | VT_BYREF))
// only here you can change the type of passed variable (see VB example below)
VARIANT *p2 = V_VARIANTREF(p);
p2->vt = VT_BSTR;
p2->bstrVal = SysAllocString( L"abc" );
Dim v As Variant
v = 1
Debug.Print TypeName(v) & " " & v
Debug.Print TypeName(v) & " " & v
On one side I have a C# application (WPF) from which I want to call an Office Add-In class. On my Office Add-In project I've exposed a class and an interface to COM. I'm able to call functions from my exposed Add-In object, but I'm not able to register an event, which should by fired by the exposed Add-In project.
My C# code:
officeAddIn = excel.COMAddIns.Item(ref addinName);
object obj = officeAddIn.Object;
IAddInUtilities m_excelFIMAddInUtils = (IAddInUtilities)obj;
AddInEnablingEventHandler addInEnablingEventHandler = new AddInEnablingEventHandler(m_excelFIMAddInUtils_AddInEnablingEvent);
//Until here, it works finem_excelFIMAddInUtils.AddInEnablingEvent += addInEnablingEventHandler //Failes! --> InvalidCastException
I found out a solution that works. If someone has a better working solution, please post it
The code snippet of my new code in C#:
m_excelAddInUtils = (IAddInUtilities)obj;
// create a Channel with port 0 --> otherwise an Exception will be//throwed: "This remoting proxy has no channel sink which means either //the server has no registered server channels that are listening, or //this application has no suitable client channel to talk to the server.
IpcChannel serverChannel = new IpcChannel("localhost:0");
//Use a second instance of the utility class. With the first instance provided by the COMAddIn.Object property, I //haven't found out how to marshal an event registering without throwing //an InvalidCastException
AddInFIMUtilities addInUtilClass = new AddInFIMUtilities();
//Register the second instance (CLR object) to the COM instance over the //provided utility interface
//Now the event registering works without cast exceptions
addInUtilClass.AddInSaveEvent += new AddInSaveEventHandler(addInUtilClass_OnFIMSaved);
The new delegate in Add-In class:
On the Add-In class I created a new IDispatch Interface:
//Service to register the CLR client object to COM observer list
void AddToSaveObserverList(IAddInUtilities addInUtils);
When I try to play an .avi file in a Windows Media Player component, it is like 1 second black between each new play. It says 'Media has been found' (a translation of myswlf of the Dutch version). Is this solvable? The avi file is a copy of the Vista copy file dialog which musn't be black between every loop.
I'm automating MS Word and so far I've found out that the easiest way to do it is to put as much of the code as possible in VBA macros (in a *.dot file loaded through COM automation), and call those macros.
The problem is I can't pass arguments to MyMacro1, and I need to in some cases. CApplication::Run accepts only 1 parameter and that's the macro name. But how can I pass additional arguments to the macro?
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
I am trying to call an activeX method from JScript in IE6. The method we are trying to call takes two arguments: one long which is the dimension of the array (of bytes) passed as the second parameter. In some cases the size can be zero and the array undefined and we are in that case.
How can I call this method from my JScript code? I tried obj."method(0, null);" but I get an incompatible type error. I also tried using Scripting.Dictionary object but to no avail. Has anyone a tip for this ?
I'm building .NET application that uses DirectX API for web camera device rendering.
I'm using DirectShowNet Library as wrapper for more info see here DirectShow.NET[^]
When I create instance of for ICaptureGraphBuilder2 interface and call RenderStream like bellow
where capFilter is my source filter,everything is OK.
But after releasing the resources and recreating the graph and the ICaptureGraphBuilder2 instance when I call the method RenderStream it failes with return code -2147024809 or HRESULT E_INVALIDARG.I've tried to call it like
,where target is my target filter,but this failes again with the same return code.When I change the category to PinCategory.Preview I'm also getting the same result.
I can't avoid using ICaptureGraphBuilder2,because I need to control the resolution of the device.
Do you know how to fix it?
Thank you very much!
working with some closed-code client/server application - the client reaches the server using a COM object thats defined by a InprocServer32 DLL - I would like to split client and server to different machines.
DCOM at first sight cannot do it - as the COM is a InprocServer32 DLL (for remoting a LocalServer32 COM - EXE seems to be necessary - Racmgr32 only lists these COM class entries).
My first thought was to code a InprocServer32 COM EXE that provides the same classes like the InprocServer32 DLL does. After I would generate the TLB of the DLL an generate a InprocServer32 DLL that has the same classes and interfaces, but just calls the LocalServer32 EXE - which after could be remotely used by help of DCOM. I guess this has do be done because if I just deleted the InprocServer32 class entry, the current creating method in my client-EXE would not be able to deal with the LocalServer32 COM class anymore.
My question now is - would You guys do it the same way? Does anyone know a way how to make a InprocServer32 DLL being usable remotely - for example by hooking up CreateDispatch? If I would do it the way I described - does anyone see problems or shortcomings? I am thankful for every articles and informations You drop!
Thank You very much for Your ideas, thoughts and replies!
Last Visit: 31-Dec-99 19:00 Last Update: 5-Dec-23 14:22