|
Hi!
I'm trying to implement a event that fires an UDT which contains another UDT. I have some doubts and questions. Here is the idl code:
typedef enum <br />
{<br />
S1_item1 = 0,<br />
}enumSample1;<br />
<br />
typedef enum <br />
{<br />
s2_item1 = 100,<br />
}enumSample2;<br />
<br />
typedef struct<br />
{<br />
BSTR m_string1;<br />
<br />
enumSample1 m_enum1;<br />
enumSample2 m_enum2;<br />
}st_NestedUDT;<br />
<br />
typedef enum<br />
{<br />
s3_item1 = -1,
s3_item2 = 0,<br />
}enumSample_3;
Q1: Is the s3_item1 ok? I read somewhere that enums are finally unsigned short.
typedef struct<br />
{<br />
enumSample_3 m_eS;<br />
<br />
}st_MainStruct
Q2: Should be the nested UDT member a VARIANT or just a st_NestedUDT member?
//------------------------------------------------------------------------
And the event is like:
[id(2), helpstring("method OnNewOrder")] HRESULT OnNewOrder(st_MainStruct stInfo);
And finally, how should I encapsulate the stInfo in order to call Invoke? My first thought was:
IRecordInfo * pRI;<br />
<br />
hr = GetRecordInfoFromGuids(LIBID_MyLibraryLib, 1, 0, 0, IID_st_Main_Struct, &pRI);<br />
if(FAILED(hr))<br />
return hr;<br />
<br />
CComVariant avarParams[1];<br />
avarParams[0].vt = VT_RECORD;<br />
avarParams[0].pvRecord = stInfo;<br />
avarParams[0].pRecInfo = pRI;<br />
<br />
CComVariant varResult;<br />
<br />
<br />
DISPPARAMS params = { avarParams, NULL, 1, 0 };<br />
hr = pConnection->Invoke(2, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, ¶ms, &varResult, NULL, NULL);
Q3: Is that right?
Thank you in advance
Gizzo
|
|
|
|
|
Hello All,
I am new to COM world.
In COM is it possible to have a property with two parameters? For example:
GetValue(index, Value)
PutValue(index, Value)
Does COM allow this kind of definition in IDL file. What are pro and cons of this definition. If i declare a property with two paramters, how I will be able to use it in say C++?
Any one? Any idea?
Thanks in advance,
|
|
|
|
|
ckapil wrote:
In COM is it possible to have a property with two parameters?
Yes you can put it!
ckapil wrote:
Does COM allow this kind of definition in IDL file.
I am working on it,Will send you Source Code and Sample Application, if i am SuccessFul!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Good News for you!
i Successfully Created the Com Dll and Client Exe using double parameter Property!.
please send me your Email so that i send it to you!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
|
I am trying to update an ISequentialStream object in a RowSet in SQL Server. But am getting the following errors:
- Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
- String data, length mismatch
The "String data, length mismatch" one is troubling me. And I think it has something to do with the way I am creating the stream. This is the methodology I am trying to implement:
IStream *pIStream;
CreateStreamOnHGlobal(NULL, true, &pIStream);
pIStream->SetSize(x);
pIStream->Write(databuf, databuf_len, &byteswritten);
ISequentialStream *pISeqStream;
pIStream->QueryInterface(IID_ISequentialStream, (void **)&pISeqStream);
I am struggling with the length. As to what it should be set to. I have done a simple test to try and write a 6 character string. The size of the stream created is 6 bytes and I have set the size of the length in the bindings for the rowset to be 6. Yet I am getting a string length error on Update ...does a null terminator for the string have to be allowed for somewhere.
Any help on what I may be doing wrong here would be appreciated. Thanks.
|
|
|
|
|
If I do an GlobalAlloc and copy the data into this block of memory and pass that to the CreateStreamOnHGlobal function instead of using the IStream->Write function it works without an error.
But as far as I can tell, the size of the streams created using both methods are the same, and the memory allocated to each is the same.
|
|
|
|
|
I am trying to build a shared library (DLL) from m-File.The problem is that I need to use the graphics library.I know that I must bundle the libmwsglm.mlib library(using the command mcc) but I couldn't find how do it . Now I'm looking for a way to create a .dll (using graphics library)and after use it for example in C#.I think that somebody can help me and your help will be very useful for me.
Regards,
Marcel
|
|
|
|
|
Hi there,
I have built a COM component that makes available data from a device. The data is potentially confidential (commercially that is!), so I would like to limit the use of my component. Basically I want to only allow something else I have written to access its interfaces.
Can anyone give me an idea as to what the best solution for this is ...?
Apologies if this Q has been raised before, this is my first visit ...
Regards,
Rob.
|
|
|
|
|
Ok, I found out a way
I'll put it below in case anyon searching this place needs something similar. Thanks anyway ...
// In Server
// Define the license class - to be used by your ATL COM class
class CWrapperLicense
{
protected:
static BOOL VerifyLicenseKey(BSTR bstrKey)
{
CComBSTR inKey(bstrKey);
CComBSTR realKey(L"RobsHardcodedOneAndOnlyLicenseKey");
if (inKey == realKey)
return TRUE;
else
return FALSE;
};
static BOOL GetLicenseKey(DWORD dwReserved, BSTR* pBstrKey) {return FALSE;};
static BOOL IsLicenseValid() {return FALSE;};
};
// Add to your ATL COM class
DECLARE_CLASSFACTORY2(CWrapperLicense)
// This tells your class to implement the default interfaces for classfactory2
// These are then overridden in your CWrapperLicense
// In Client
CComPtr<IClassFactory2> spCF2;
CComPtr<IATLCOMClassDefinedInServer> spServerClass;
CoGetClassObject(CLSID_ATLCOMClassDefinedInServer,CLSCTX_INPROC_SERVER,0,IID_IClassFactory2,(void**)&spCF2);
spCF2->CreateInstanceLic(NULL,NULL,IID_IATLCOMClassDefinedInServer,L"RobsHardcodedOneAndOnlyLicenseKey",(void**) &spServerClass);
|
|
|
|
|
I've engaged in a project with the function of displaying DOC and PPT files.
It means that my program can display DOC and PPT files without displaying the menus and toolbars of the MS Office, how can I get it done.
I searched a lot of documents about the Office Automation,but I found none suitable for me.
Thanks for you help!
|
|
|
|
|
I gave you some feedback in the C++ forum.
"Live long and prosper." - Spock
|
|
|
|
|
Hi figer,
In COM terminology DOC and PPT files are called as Active Documents
By my personal experence you must start reading about Active Document, Active Document Server, Active Document Containers etc.
Okay so you want to display the DOC, PPT etc files inside your appication...
For this purpose your application must be an Active Document Container...
For more information search the microsoft KB articles named "DSOFramer"
I have strong felling, this is what you wanted...
And about Office Automation. If the above concepts are clear then I dont think Office Automation is an issue....
Have fun buddy !
Happy programming
Cheers,
Vishal
|
|
|
|
|
I need some help in codding ActiveX container. Short description : Microsoft Visual Studio 2003 and other vsersion (6,7) , includes sample TstCon - a sample of ActiveX Container. When I place control and than delete it or open new document, this program hang up every time when i close it.
I modified ContainerItem method OnDelete()... after pItem->Delete() i put delete(pItem); its all works under win2k... but... in 98SE,XP after deleting control, when i try to insert new control an error occured "Failed to connect.Link may be broken".
So does any one knows how to solve this, and force it to work correctly.
Thanks.
|
|
|
|
|
Hi,
I am new to COM.I have one application(Say simulator) which is interacting with control software on the same machine.Now i want to it to work through remote machine.Can you please let me know how this functionality can be achieve.If you know similar url please let me know.
Thanks
|
|
|
|
|
Assuming you are not using smart pointers, the code will go as follows:
{
COSERVERINFO csi = {0};
MULTI_QI qi[1] = {0};
//Init pwszname to computer name of remote server where
ur COM server
//is to be deployed
csi.pwszName = L"xxxx"; //use proper comp name here
qi[0].pIID = &IID_IFoo; //Init to interface you wish to obtain
HRESULT hr=CoCreateInstanceEx(CLSID_Foo,NULL,CLSCTX_REMOTE_SERVER,&csi,1,qi);
if(SUCCEEDED(hr))
{
m_pFoo=(IFoo*)qi[0].pItf;
//you got the interface for remote machine.
//Do your work here
}
}
This method is to programatically set up the connection to remote server
Another easy method is to register your COM server on both the local and remote machine. Launch 'dcomcnfg' on the maching you plan to run client. Find your COM server from the objects in the list view, right click and click 'properties'. Check the box 'Run this component on' and key in the name of the remote machine you paln to install your COM server.
That should work fine. No significant changes are required to the basic functionality of the COM server and the migration to DCOM server should be breeze
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
Hi all,
I've got a problem- I'm attempting to write an unmanaged c++ COM client for
a c# COM server. I wrote an event sink to handle events dispatched from the server. The problem- Events are properly intercepted by the client when in "blocking mode" but does not seem to work when in "non-blocking mode", i.e: When I implement the logic in a seperate thread.
I'v read about it some and I think this is because the thread enters a new apartment which the client sink is not in or something of that sort. How do I
overcome this problem?
Thanks in advance and sorry for by *bad* english..
i.chen
|
|
|
|
|
attention
|
|
|
|
|
pWebBrowser2->get_Document(&pDisp);
IHTMLDocument2Ptr pHTMLDoc2(pDisp);
IHTMLElementCollectionPtr pHTMLColl;
pHTMLDoc2->get_all(&pHTMLColl);
pHTMLColl->tags(_variant_t(TEXT("a")), &pDisp);
pHTMLAColl=pDisp;
The problem here:
pHTMLColl->tags(_variant_t(TEXT("a")), &pDisp);
On C++ works well, but on MASM returned:
DISP_E_MEMBERNOTFOUND
|
|
|
|
|
Hello all.
I've authored an ActiveX-control that i'd like to put on my web page. (yes, it's worth downloading)
But XPsp2 requires that the control be signed. (Or did it require that before sp2?)
Verisign takes a fortune for a publishers certificate, so does anyone know an alternative? One obvious alternative is to let the users download an installer, but that's not at all as compelling as a real control..
The microsoft documentation on authenticode speaks about a certificate type for "individuals", but I can't seem to find a way to get such a certificate?
|
|
|
|
|
Have you implemented the IObjectSafety interface for your activex control ?
Cheers,
Vishal
|
|
|
|
|
|
Hi,
Right now I'm working on dynamically adding DLL's to my menu.
But I cannot typecast the function pointers (I'm not exporting any class from my DLL)dynamically in my caller application.
Please help me in this.
Thanks
Sijis'
|
|
|
|
|
Could you be more specific?
You can't just arbitrarily typecast a function entry point to be anything you want. The function is going to expect certain things on the stack in order to execute properly.
By "dynamically" I assume you mean at run-time. Or, are you getting compile errors using GetProcAddress?
An example of properly casting the return of GetProcAddress:
void (*pFunc)(int) = (void (*)(int))::GetProcAddress(hModule, "MyProcName");
This example defines the variable pFunc as a pointer to a function that returns void and takes one int argument then initializes the variable to the return value of GetProcAddress() function. This assumes that MyProcName is defined as void MyProcName(int) in the source for the DLL.
These issues have been addressed with COM; I would suggest using COM rather than DLL entry points, expecially if you're not dealing with 3rd party binaries.
PeterRitchie.com
|
|
|
|
|
Hi there,
We have an application that accesses OPC Servers on an ethernet network. OPC (Ole for process control) uses DCOM to transmit information. To get a connection through DCOM we need to change certain security settings with the DCOMCNFG tool. Because this is very error prone for customers, I need a way to do this programmatically during setup.
Does anybody have code snippets of how to change these settings or does anybody know which methods to call to do so? I prefer examples in C# or C++ but if you have any information it would help me anyway.
Best regards
Daniel
|
|
|
|
|