|
Are you sure IStream can be used to write to a text file? I've always used it for writing to a structured storage file. If I'm wrong and it will write to a text file, have you opened the stream in transacted mode and so have to call ISteam->Commit to make any IStream->Write calls be seen in the ouput file?
|
|
|
|
|
Hi,
I am a newbie to the COM and Microsoft technologies. i have a COM dll to be used in my C++ program to connect to remote server and handle events recieved from the remote server.
COM dll contains the single interface and following functions are available
setIpAddr()
setPort()
Connect()
startRequest()
Also available events are
onConnect() :- occurs when the server responds to to Connect() call above
onRecieveData() :- occurs when the call startRequest() is made and this is continuous event happens when ever the remote server sends the message.
I am able to create the COM object and call the methods. my question is, how take care of the event handlers.(creating stubs for the events above).
Here is the code snippet
#include "stdafx.h"
#using <mscorlib.dll>
#import "XYZCom.dll"
#include <string>
using namespace System;
int main(){
XYZCom::ITXYZCom *interfaceXYZ = NULL;
HRESULT hr;
CoInitialize(NULL);
hr = CoCreateInstance ( __uuidof(XYZCom::ITXYZCom), NULL, CLSCTX_INPROC_SERVER, __uuidof(XYZCom::ITXYZCom), ( void** ) &interfaceXYZ );
if( ! SUCCEEDED( hr ) )
{
interfaceSinal = NULL;
printf( "Unable to create instance of the object.\n" );
// goto _EndMain;
}
interfaceXYZ->setIpAddr("127.0.0.1")
interfaceXYZ->setPort("15000")
interfaceXYZ->Connect();
Google talks about ATL i am not sure about it. How to implement the event handlers for the event interfaces defined in the COM DLL
|
|
|
|
|
|
How To pass structure or complex data in IDispatch using invoke() method.
The COM server component is third party's so I donot have control on what defined in IDL or whatever technology they used. for example I want to pass complex data or structure like below to invoke() method.
struct tag{
int i[10];
char str[40];
}sample;
Below is sample code to access method passing argument.
// Code omitted for brevity.
szMember = “On”;
dispparams.rgvarg[0].vt = VT_BOOL;
dispparams.rgvarg[0].bool = FALSE;
dispparams.rgdispidNamedArgs = &mydispid;
dispparams.cArgs = 1;
dispparams.cNamedArgs = 1;
hresult = GetIDsOfNames(IID_NULL, &szMember, 1,
LOCALE_USER_DEFAULT, &dispid);
hresult = pdisp->Invoke(
dispid,
IID_NULL,
LOCALE_USER_DEFAULT,
DISPATCH_PROPERTYPUT,
&dispparams, NULL, NULL, NULL);
I need to pass one argument in IDispatch's Invoke method as below . This is sample code from c# client. I already have client C# code working. I want to pass structure which has byte array and string etc in c++ using IDispatch. How usually people pass structure as single argument in IDispatch's Invoke method()
public class BLOB {
/// <remarks/>
public string contentType;
public System.Byte[] binaryData;
public string ID;
public string URL;
}
OR
If above is complex is anyone know how to pass structure like below in IDispatch's Invoke() method. The COM Server is third party.
struct tag{
char str[100];
void *p;
char str1[300];
}
modified on Tuesday, January 20, 2009 2:23 AM
|
|
|
|
|
How usually people pass structure as single argument in IDispatch's Invoke method?
Personally I'd go for a VARIANT containing a SAFEARRARRAY which in turn contained the structure.
Though your structure doesn't look to COM friendly, especially the void pointer. Have a look at this http://www.microsoft.com/msj/0696/activex0696.aspx[^]
|
|
|
|
|
Hi,
Can you please provide the method signature that you want to access?
you cannot send the structure just like that to a method in COM.
Only you can pass the arguments that are agreed in the IDL of the COM server.
you can find the signature using the OLE VIEWER.
^-^
@|@
- redCat
|
|
|
|
|
Hi,
I have a COM component written in .Net and hosted in a COM+ server application so that only 1 instance of the component will exist on a box at a given time. Multiple different applications will be accessing the COM component: Matlab, VB Script, .Net application, etc...
When the COM component is instantiated from VB Script or Matlab, I can see the COM+ server starting properly and can verify that only 1 instance of my object is created.
My problem arises when the COM component consumer is a .Net application. Basically, it seems .Net always resolves the location of the DLL and since it is a .Net DLL, always instantiate the object directly, skipping the COM+ mechanism. It seems obvious why .Net behaves that way to get rid of COM overhead, but this is causing problems in my design since I want only 1 instance of my COM Component to exist on a box at one time.
So the question is how can I instantiate a .Net based COM component hosted in a COM+ server application from a .Net application by using the COM+ mechanism?
Thanks
|
|
|
|
|
I have written a custom tool.
It generates a dll that I then have to manually register with gacutil, regasm, and add a key to the registry.
I'd like to be able to distribute this with a setup project.
Unfortunately I can't seem to get a setup project created to install this.
Has anyone here done this before? Or know of an article explaining how to do it?
Thanks,
-C
|
|
|
|
|
I am a newby to COM (ActiveX) Programming and i have a problem regarding a activex control created with the MFC Wizard.
This activex control is derived from a static control and is used to draw diagramms. The drawing of the diagrams itself is working fine. The control evaluates some mouse events (LButtonDown, LButtonUp, MouseMove) to draw extra lines or rectangles to the control.
When using the activex control in the ActiveX Testcontainer the drawing regarding to mouse events is working fine, but if i include the activex control to a dialog based application the control does not respond to any mouse event when clicking or moving the mouse over the control.
How can i setup the activex control in the dialog so that it responds to mouse events or is the problem part of the activex control itself.
Thanks in advance
|
|
|
|
|
override PreTranslateMessage in the dialog, and provide these messages to your ActiveX.
Greetings from Germany
|
|
|
|
|
I tried it but it is still not working
Best regards
|
|
|
|
|
Try to set the Control Parent property of the Dialog to true.
«_Superman_»
|
|
|
|
|
Hi all,
Is anyone aware of why some of the events in PowerPoint do not fire.
The WindowBeforeRightClick in particular is the one I wish to trap so that I can prevent the right click menu from appearing.
I'm using Office 2000.
Thanks
Cheers
Tom
Philosophy: The art of never getting beyond the concept of life.
Religion: Morality taking credit for the work of luck.
|
|
|
|
|
Hello all:
At first , I make a ocx control which build a SSL connection by OpenSSL ,and then ,I want IE can share this connection ,which means that IE do not need SSL authentication again ,so IE can connect the WEB server on the SSL tunnel.
Now,SSL connection is built by OpenSSL. But ,I do not know IE how to share the SSL connection.
Any hits is welcomed !
Thank you very much!
|
|
|
|
|
|
Hello Garth J Lancaster:
Thank you for your rely firstly.
But, I have built a SSL connection using OpenSSL. And I put this function in a ocx control ,then put this control into Web page . After connecting the WEB server by this control ,I want that IE can keep this connection(SSL tunnel), and keep accessing the WEB server by this connection.
Now, I do not know how to keep this connection ,which is built by myself in IE.
Ssl proxy maybe is not my need ,because I want to implement this function by myself,not third-part software.
Thank you all the same.
Any other hits ?
Lampa
|
|
|
|
|
I wasnt suggesting you buy/purchase the product, it was for the 'idea'. I dont think you're going to be able to 'replace' the SSL functionality in IE or the IE Control (I seem to remember there being such an object) .. ergo you're going to need to tunnel/proxy using your OCX
If its the wrong idea, 'good luck and keep looking'
'g'
|
|
|
|
|
Thank you for your reply.
I understand what your mean. and I will find out this answer.
PS, i have another question: when I build the SSL connection by IE ,Then ,I click the superlink ,which forward to another web page .why not need to SSL authentication again in this way. Do you know what happened ?
Thank you !
Lampa
|
|
|
|
|
Hi all,
I'm automating Excel from within an ActiveX control and I'm wondering if anyone knows how to highlight the contents of a cell.
I'm writing a specialised search routine and I have no problem finding the cells I want but when I select them only the perimeter of the cell gets highlighted. I'm after being able to highlight the contents but haven't found what I need in the type library. Recording a macro didn't throw any light on the issue either.
Thanks in advance for any ideas.
Cheers
Tom
Philosophy: The art of never getting beyond the concept of life.
Religion: Morality taking credit for the work of luck.
|
|
|
|
|
there's some code following from a MS MFC example : Look at excelApp.GetRange(COleVariant("A1"),COleVariant("C6")).Select();
does that help ?
'g'
#include "excel8.h"
// ...
OleVariant covTrue((short)TRUE), covFalse((short)FALSE), covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
_Application excelApp;
if(!excelApp.CreateDispatch("Excel.Application"))
{
// error handling
}
excelApp.GetWorkbooks().Add(covOptional);
excelApp.GetRange(COleVariant("A1"),COleVariant("C6")).Select();
excelApp.GetActiveCell().SetFormula("Hello World!");
excelApp.SetVisible(TRUE);
|
|
|
|
|
Thanks for the response.
Adding text as you have done seems to change it somewhat. Unfortunately, I'm dealing with read only files and as such I'm only trying to highlight what's already present. The call to Select() doesn't highlight the content, only the outline of the cell
Thanks though
Cheers
Tom
Philosophy: The art of never getting beyond the concept of life.
Religion: Morality taking credit for the work of luck.
|
|
|
|
|
Hi,
In my application i am using ActiveX control(creted by .net2.0) to capture PrintScreen image.
when i am using it through http://localhost it gives error
Request for the permission of type ‘System.Security.Permissions.UIPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′ failed
But when i run same page by using computer name its work i.e.
http://computername/Applicationname/xyz.aspx
How to give permission for activeX.
Thanks in advance.
|
|
|
|
|
hemant.kaushal wrote: How to give permission for activeX.
Use DCOM config admistrative utility.
|
|
|
|
|
is anybody know how to create a COM wrapper around the C# class.
Please let me know full tutorial or any links having relevanmt information
Thanks in advance
Datta
|
|
|
|
|
You should read the documentation that comes with your compiler. There's tons of material on NET and COM Interop.
Over at MSDN: Exposing .NET Framework Components to COM[^] is as good a place to start as any.
Another reference is: How to Create COM Wrappers[^].
I've read that you can do this with your source code, but, it is an extremely error prone process, as .NET types don't always map unambiguously to COM types.
|
|
|
|