|
Hi
I've COM exe server. It registers on WinNT based platforms.
I can't register it under Win98.
It is possible to do this ?
I've error in
_Module.UpdateRegistryFromResource(IDR_AtlExe, TRUE);
hRes is 0x80040154 (class not registered).
In all others calls before _Module.UpdateRe... are ok (hRes is 0).
I use VC 6 with sp5 and simple code generated from ATL wizard with one interface with one method.
Thx 4 Hlp
|
|
|
|
|
InvokeHelper() function...
//MSDN says
This method calls the object method or property specified by dwDispID, in the context specified by wFlags. The pbParamInfo parameter specifies the types of the parameters passed to the method or property. The variable list of arguments is represented by ... in the syntax declaration.
well, that is what MSDN says about InvokeHelper method of COleDespatcher class.
Now My confusion is....
I am trying to understand a project, which is an activex control whose purpose is to display some graphical interface to the data given from a server.
Here the OCX project is using another library which is a wrapper for another library, customized to the requirements of OCX project.
When I tried to trace how the flow of function call is going on..
it is happening like this..
my ocx project is calling method from wrapper project which is using InvokeHelper(..).
my collegue says "it is all com funda".. and he showed me a method in another project where actual code is present.
The function call is something like this.
InvokeHelper(0xa, DISPATCH_METHOD, VT_BOOL, (void*)&result, parms,<br />
iTraceNumber, &strTraceId, strSource);<br />
But How do I come to know what is happening here..
it is all confusing.
any ideas..?
meanwhile I try to go thru the COM section of codeguru and codeproject.
Thanx in advance
Harinath
Harinath Reddy
HOneywell Technology Solutions Lab,
Bangalore,
India-560076
|
|
|
|
|
Hello,
is there a simple way to call the javascript escape function from c++ app (mfc)?
I need to generate a html slideshow from a selection into a database, but it seems that certains strings (valid in c++) can be invalid in the html file.
For ex : "\\test\\" in c++ are generated into "\test\", so the last \" break the string
So my idea is to add an unescape into the generated html, but the counterpart is a call to escape in the c++ part...
I already embed an IE browser in my application.
Another bad point is that all calls are in a loop, so I want to avoid slow calls !
Thanks in advance
Thierry
Isotools Software Engineer
|
|
|
|
|
Could someone enlighten me on how to retrieve the name of an object implementing IDispatch? With the name I mean the coclass-name as specified in the IDL-file.
--
"It's a condition of mental divergence, I find myself on the planet Olgo part of a intellectual elite, prepared to subjugate the barbarian hordes on Pluto, but even though this is a totally convincing reality for me in every way, nevertheless Olgo is actually a construct on my psychee. I am mentally divergent in that I am escaping certain unnamed realities that plague my life here."
|
|
|
|
|
See the implementation of XYDispDriver::LoadTypeInfo in XYDispDriver.cpp from this article[^]'s sources. It's not exactly what you need but could be a good starting point.
rechi
|
|
|
|
|
hi there..
i am quite a situation here..
how do i get to the outer unknown of the controlling Unknown?
HELP..
regards
|
|
|
|
|
Hi everyone,
I get the following error message from Outlook when I try the saveas command: “Unable to coerce parameter value: Cannot translate your string”.
Code example:
szFunc = OLESTR("SaveAs");
hr = m_pDisp->GetIDsOfNames(IID_NULL,
&szFunc,
1,
LOCALE_SYSTEM_DEFAULT,
&dispID);
if (FAILED(hr))
{
cout << "GetIDsOfNames failed on SaveAs";
return;
}
CComVariant vPath(strPath.GetString());
CComVariant vType(Outlook:lMSG);
VARIANT pVal[2];
dp.cArgs = 2;
dp.cNamedArgs = 0;
dp.rgdispidNamedArgs = 0;
dp.rgvarg = pVal;
pVal[1].vt = VT_ERROR;
pVal[1].scode = DISP_E_PARAMNOTFOUND;
pVal[0].vt = vPath.vt;
pVal[0].bstrVal = vPath.bstrVal;
EXCEPINFO excep;
hr = m_pDisp->Invoke(dispID,
IID_NULL,
LOCALE_SYSTEM_DEFAULT,
DISPATCH_METHOD,
&dp,
NULL,
&excep,
NULL);
if (FAILED(hr))
{
cout << "Invoke failed on SaveAs";
ErrHandler(hr, excep);
return;
}
Any help would be greatly appreciated.
Thanks,
Ken
|
|
|
|
|
Hi, I have an application with some disptach interfaces. I can access these interfaces via vb-script without any problems, but when I use constants (I defined an enum) vb-script does not seem to recognize them. The weird part is that I have a function that returns an enum value and that value is received correctly in my vb-script, but when I do a compare with the enum constants, all constants are 'Empty'.
Anyone knows what the problem is? Must I do someting other than just declaring an enum in my idl file?
|
|
|
|
|
You can't access anything from the idl but some of the coclasses. Probably the enum constants are implicit variables; have you declared Option Explicit in the script?
Brian van der Beek wrote:
The weird part is that I have a function that returns an enum value and that value is received correctly in my vb-script
It works because the enumeration is VARIANT -compatible. Try with a struct and see how it fails.
rechi
|
|
|
|
|
I'm relatively new to scripting and did not know about Option Explicit , it makes this a lot more clear.
I did some more digging and found out that you indeed cannot use constants/enums from a idl/tlb. You should be able to do this when you do early binding (e.g. Dim excel as exec.application), but I don't think you can do this in vb-script.
|
|
|
|
|
Anonymous wrote:
you indeed cannot use constants/enums from a idl/tlb
I'm not sure about this issue. According to MSDN, ITypeInfo supports enum type description so it should be available even by late binding. VBScript doesn't support it, that seems to be true.
rechi
|
|
|
|
|
I am working on a COM Server with numerous C++ classes in it . I was trying to use the Multimedia timer . I found that I couldnt access class pointers from the Timer callBack function. That is when I decided I need to perform Marshalling . I just know that I need to Use CoMarshalInterface and CoUnMarshalinterface.
I was wondering if someone could point to some useful examples or links that contain tutorials about this as these calls involve these parameters
IStream *pStm,
REFIID riid,
IUnknown *pUnk,
I d like to know as to how to create these parameters and pass them .
|
|
|
|
|
well, in overview, it's pretty simple.
On the beginning, you have to have some interface pointer you want to marshall - say, it's IMyInterface .
You have then to call CoMarshalInterface , but for that you need to have some IStream available. This one, you can create by calling:
CreateStreamOnHGlobal(NULL, TRUE, &_pStream);
then you can call
CoMarshalInterface(_pStream, IID_IMyInterface, IMyInterface*, ctx, NULL, flags );
So referring to your question:
IStream - it is some stream pointer created before calling the marshall method. Into this stream will be written all info required for later re-construction of the interface. You can use anything what supports IStream , even your own object. The marshaller just writes some info to the stream during marshalling and later during unmarshaling he reads the info back. The CreateStreamOnHGlobal creates a built-in object that provides IStream over the memory.
REFIID - it is an IID of the interface you want to marshal. You can use even IID_IUnknown , but then after unmarshalling you'll get the IUnknown back
IUnknown* - it is a pointer to the interface you want to marshal. It is IUnknown , because all COM interfaces are derived from it, so you can cast any COM interface to IUnknown .
Then you have to deliver the IStream to the another thread (or application or whatever - depending on flags), and call
CoUnmarshalInterface( stream, IID_IMyInterface, (void**)&_pMarshalledPointer );
and you are done.
If you doing it in-process and using ATL , consider using
AtlMarshalPtrInProc
and
AtlUnmarshalPtr + AtlFreeMarshalStream
They does the IStream creation for you (but they are only in-process)
I hope this helps you a bit. In case if something is unclear, don't hesitate to ask
|
|
|
|
|
Thanks for the info . Very useful.
I am developing a COM Server(COM A) that has numerous classes within
and also interacts with another COM Server(COM B) housed within this
Server .
I was able to use the MultiMedia timer in a class of COM A fine but have trouble when i try to accessCOM B related pointers from the TimerCallBack which normally I was able to access within COM A.
That is the point where Marshalling comes in .
I read about the functions and have certain questions .
1. Where should I do Marshalling .
there is a class(CBridge) in A that exposes COM B component. Can I
perform the call to CoMarshallInterface when CBridge comes up .
2. Do I have to write something into the IStream while Marshalling .This question is governed by what I need in the TimerCallback func . I
need to successfully be able to call COM B pointer from within COM A .
I created a Stream using
CreateStreamOnHGlobal(NULL, TRUE, &_pStream);
Do I have to do a Write on this Stream
3. I assume I have to UnMarshall in my timerCallback func . I have the
stream available , the RIID , I am unclear about the 3rd Parameter .
4. Finally after UnMarshalling how would I use COM B pointer from within
the TimerCallback !
|
|
|
|
|
1. Well, you can marshal only the COM interfaces, not normal classes. If I understood it correctly - the CBridge is a part of COM A . Then I'll keep the marshaling details inside the CBridge and call the CBridge methods as usual. When there's a need to return pointer to COM B from CBridge , it should be already marshaled.
2. No. The COM subsystem writes everything he needs inside the CoMarshal...
3. The third parameter is a pointer to pointer to the interface you want to unmarshal - this is the result of all the pain - marshaled interface . You have to simply:
IMyInterface* ipInterface = NULL;<br />
CoUnmarshal( stream, RIID, (void**)&ipInterface );<br />
if( ok && ipInterface )<br />
ipInterface->Method();
4. as any other pointer. The process is somehow transparent - the marshaled pointer looks exactly the same, only pointing to diferent object (some internal stuff of COM).
Only I would add, is that if you need behavior marshal once, unmarshal more times, you have to look at the GIT (as someone in thread mentioned). The read from IStream inside CoUnmarshal is destructive and you cannot use the IStream any more.
As the marshaling stuff is quite complicated, don't worry to ask more
|
|
|
|
|
In addition to the geo_m's explanation, check this link[^] in MSDN.
Using the GIT is the easiest method, IMHO.
rechi
|
|
|
|
|
Hello,
I have a web browser control in my dialog and I want to resize the control to fit the html inside.
First of all, is it actually possible to get the size of the document/top frame?
There is only one frame in the document and I'm hoping to read it's height and width properties, but I've been trying to drill down to the Frame but I keep getting an error. I've checked a lot of the newsgroups and I think I'm going through the IE DOM correctly. I'd appreciate any help.
Thanks,
John
IDispatch* spDispatch = NULL;
IHTMLDocument* m_spDoc1 = NULL;
IHTMLDocument2* m_spDoc2 = NULL;
IHTMLFramesCollection2* m_pFrames = NULL;
HRESULT hr = NULL;
spDispatch = m_browser.GetDocument();
spDispatch ->QueryInterface (IID_IHTMLDocument, (void**)&m_spDoc1);
m_spDoc1->QueryInterface(IID_IHTMLDocument2, (void**)&m_spDoc2);
m_spDoc2->get_frames(&m_pFrames);
//the following code was taken from an example
//which iterates through the frames
/ but since my page has just one frame, frameCount returns 0
//and since it is zero based I'm presuming this is correct
LONG framesCount;
m_pFrames->get_length(&framesCount);
for( long i=0; i <= framesCount; i++)
{
VARIANT varIdx;
varIdx.vt=VT_UINT;
VARIANT varResult;
varIdx.lVal=i;
VariantInit(&varResult);
hr = m_pFrames ->item(&varIdx, &varResult);
if (SUCCEEDED(hr)) // always fails here
|
|
|
|
|
Found some code on the newsgroups
Here[^]
|
|
|
|
|
error C2440: 'type cast' : cannot convert from 'const struct _GUID' to 'long'
regards
|
|
|
|
|
can you perhaps supply the code where it goes wrong.
|
|
|
|
|
return GetPredefinedStrings(UUID_BorderConstants , pcaStringsOut, pcaCookiesOut);
it says this on the first parameter..
regards
|
|
|
|
|
Seems to me you are placing a GUID in a long (figures), but the first parameter of GetPredefinedStrings must be a DISPID, which is the id you attach to a method of an interface. Like:
[id(1)] SomeMethod([in]BSTR bstrCrappyString)
the DISPID in this case is 1.
Does this answer your question?
|
|
|
|
|
oops..
exactly..my mistake
Thanks.
|
|
|
|
|
Hi, I have an application with some COM objects. Now I want to expose some of these objects the way excel does.
For example:
<br />
Worksheets("sheet1").Range("A1").value = value<br />
Does anyone know how excel exposes these Sheet objects?
|
|
|
|
|
Derive your interfaces from IDispatch if you want to be automation compatible. In Excel case the interface probably has a method called "Worksheets" which takes a BSTR param and returns a Range object :
IExcelInterface::Worksheets(BSTR sheet) : Range;
The object Range implements an interface IRange, which has a range method :
IRange::Range(BSTR range) : Value;
The value object has a property named "value".
... and so on.
All you need to do is to expose your application object model ( COM object hierarchy ) to the automation clients ( scripts, binaries, etc ).
|
|
|
|
|