|
Something like this should help:
SAFEARRAY* CFoo::DoubleArrayToSafeArray(double* array, int n)<br />
{<br />
<br />
SAFEARRAYBOUND rgsabound[1];<br />
rgsabound[0].lLbound = 0;<br />
rgsabound[0].cElements = n;<br />
<br />
SAFEARRAY* pReturn = NULL;<br />
pReturn = SafeArrayCreate( VT_R8 , 1, rgsabound);<br />
<br />
if (pReturn == NULL)<br />
return pReturn;<br />
<br />
long idxPos = 0;<br />
for (idxPos = 0 ; idxPos < n; idxPos++)<br />
{<br />
HRESULT hr = SafeArrayPutElement(pReturn, &idxPos, (void*) &(array[idxPos]));<br />
}<br />
return pReturn;<br />
}
Regards
Barry
|
|
|
|
|
Barry,
Can you point me to a good overview on the use of SafeArrays and Variants?
Thanks.
|
|
|
|
|
I spent ages trawling through MSDN I'm afraid. I would imagine that there are some articles on safearrays and variants here on CodeProject as well.
Regards
Barry
|
|
|
|
|
|
I want to design a card game ,use Com+ server.
But when 4 clients connected,it's created 4 com+ instance in server,
so it's hard to manage.
I want to know :
how I can connect every 4 clients to 1 com+ instance in server.
|
|
|
|
|
|
Hi,
I've got a CLSID for a COM object in a C++ program, how do I access methods on this object. Do I have to call QueryInterface() somehow?
I can do a CoCreateInstance() but that requires an interface ID. Assuming all I have is the CLSID, how do I do it?
Thanks!
|
|
|
|
|
Try to QI for IUnknown or IDispatch
CLSID clsid;//some valid clsid
LPDISPATCH pDisp;
HRESULT hr = CoCreateInstance(clsid,NULL,CLSCTX_SERVER,IID_IDispatch,(LPVOID*)&pDisp);
if(SUCCEEDED(hr))
{
//now call interface methods
pDisp->AutomationCall();
}
}
|
|
|
|
|
hmm, in fact, you can create the object, asking CoCreateInstance for IID_IUnknown as an Interface ID (IID). Then you will receive the pointer to the IUnknown.
But the question is what you want to do next - for nearly every other activity you will need to retrieve some interface from the object, else you will be able only to call IUnknown methods or might be IDispatch methods, but without any further info you are generally not able to perform any operation over that object.
I don't know if I expressed myself correctly, but the situation then is similar to having a .lib without header - so you have some objects inside the lib but you don't know how to talk to them.
|
|
|
|
|
I have created a COM collection object for use by our UI team, but now requirements seem to have changed and they no longer want COM collections but something like ADO recordsets they can bind to their grids. It seemed to me that a data bound control is probably just using an interface on the ADO recordset objects to navigate the collection. And since I already had my COM collection implemented, if I could implement this mysterious DataSource interface I could make everyone happy. Can anyone give me a push in the right direction? What interface do I need to implement in my COM collection to act as a DataSource for a VB Data Bound control? Thanks in advance.
|
|
|
|
|
Take a look at the ATL OLEDB data producer classes1. Many grids support OLEDB as well if I'm not mistaken..
Just fire up an ATL project, and add an OLEDB data producer class using the ATL wizard, and go on from there.
1 I'm not sure this is the correct name. I'm 100 miles from home, so I can't lookup the name right now. But just look at the ATL wizards and you'll know it when you see it.
--
Only in a world this sh*tty could you even try to say these were innocent people and keep a straight face.
|
|
|
|
|
hi,all
I write a COM Dll in Visual ATL . And I refer the COM dll in VB environment. The vb program runs well except when the program exit, the error dialog occur. The error info are such as "the address can't read ..." . Is it concerns with
the c++ pointer ??? But how can I find the actuall false??
Are there any tools to help to debug the com dll??
The problem disturb me for very long time .
Ask for your help , please !
Regards.
|
|
|
|
|
Best way is to load the ATL project to the MSVC and set up the visual basic as a startup exe. Then when you press f5, the VB will be started. You can work with the VB as you want, e.g. load some test project, but you can put the breakpoints to methods of your DLL and the execution will stop there in case it will be called...
|
|
|
|
|
hi,
thx.
I can debug the com dll following your advice.
Because just when my vb program exit the errors occurrs,
I set breakpoints in destructor function . Then when I exit the vb program ,it seemed the program did not execute the destructor code. It did not pause on the breakpoints,instead there showed a error dialog "Unhandled exception in P2P.exe : Access Violation".
If I direct run the vb program without the debug mode , when I exit the vb program I will receive such error message"the memory address can't be read..."
why?? I am exhausting now after so much try.
thx.
regards.
|
|
|
|
|
Hi,
well have not exactly an idea, only what I would check very carefully are the circular references in VB. I think, that the similar things happened to me some time ago, when I 'developed' a circular reference through three objects and the VB garbage collector didn't detect it and failed on some exception.
What can be next thing is some topics similar to it - returning a pointer to memory which is later freed inside the component (normally one should return a copy of the memory, because VB will release it later) and similar thingiez.
In short, first who will be suspect for me in such a case will be the VB garbagge colector.
|
|
|
|
|
hi
But how can I solve this problem . You know ,anyway ,if the program have such a bug ,my boss will not be satisfactory with me. I have try many times these days, but failed.
Can you give me some advice on how to resolve this problem. It'll be appreciated.
thx.
regards.
|
|
|
|
|
Yeah. Bosses are allways the same. Anyway, this is very difficult question. It depends on the program design. Normally I am checking nearly everything regarding all return values especially returning some memory structures (BSTR, VARIANTS, arrays...). Also I am checking the dependencies and ownerships you can sometimes see, that object A points to object B and object B points to object C while C points to A - this is exactly the situation where VB garbagge collector crashes. Good luck!
|
|
|
|
|
Hello,
I am trying to replay a set of recorded events in WebBrowser. I am able to record and replay the events like keypress and click events on the html page displayed in the browser.
However, when i am replaying events like keypress into a text box and then a click on submit button, the application does play the events but i am not able to see the text entered inthe text box on the HTMl page.
Similarly if there more text boxes and events are replayed on them then the text is seen only after the function for replaying of events returns.
for e.g. Google's page has a textbox and Google search button. If i just record events in the text box without clicking on search and replay them back i am able to see the text in the textbox after the replaying is complete. However if i also press click on the search button and try to replay these two events then the app puts the text and clicks the button and navigates to result page and thus the events are replayed properly, but the text is not seen in textbox before navigation.
Further info:
I am using WebBrowser in VC++ and IHTMLDocument2 pointer. With this i am able to get the HTML of the element and compare it with the recorded event's HTML. When i find the element(IHTMLElement) i use either a click() or put_innexText() api's depending on whether it was a click or a keypress event.
I have tried to run the function which replays events in OnDocumentComplete(), directly and then again inside a thread so as not to interfere with the documentcomplete process. I have also tried to use sleep in OnBeforeNavigate().
Secondly, I have tried to use PostMessage and SendMessage and keybd_event() apis to see if they make any difference. All this has failed.
Please somebody help me with this. Thanks in advance.
Regds,
Prasad.
Prasad
Thanks again
|
|
|
|
|
modified, after read it completely . just a wild shot - maybe IE needs some time to refresh it's window, or, this might depend on the app design, somehow during the playback, the IE window messages are not handled or something like that (this can be specially if your player is an inprocess component and it seems to me that it is).
If I looked to furhter info, it looks to me so, that you fill the textboxes or whatever, but there is no time to display it.
What I will try on your place is to process the messages after each change (PeekMessage, DispatchMessage...). This might help
|
|
|
|
|
Thats right IE basically is not updating the component after the text is entered. It does have the time to update it. I am iterating through a linklist picking up events and then firing them, so i just need to get out of that loop. Say for eg by displaying a dialog box.
I have currently solved this problem by using postmessages and sleep in my dll.
Thanks anyway, I will try to check out ur solution too and let u know.
Prasad
Thanks again
|
|
|
|
|
Hi All,
I'm trying to set a top-level exception call-back filter inside a com+ application server.
Although SetUnhandledExceptionFilter seems to succeed, that it returns the previously installed filter correctly, my filter never been called.
of course I'm trying to detect the call in a (release mode) through a simple code that creates a log file to be filled later with the proper informations I need for recovering.When calling the filter from a __try/__except(MyFilter(..)) block, the filter code executes correctly, but when generating a purposly unhandled exception the file is never been created.
Any idea?
Regards.
AbuMalek
|
|
|
|
|
hi,i am trying to save the ppt file into html,
and i call "saveas" to do it,but if the ppt file
is bigger ,it very slow!! how to make it faster??
welcome
|
|
|
|
|
hi all,
i want to make a plugin for my internet explorer..can i do so in vc++ or using com...i dont have any idea..if someone can help please do so..
best regards...
himanshu
|
|
|
|
|
For IE you have to play with MS COM, as everything is exported through interfaces. So you can do it in VC++ using COM .
What kind of plugin it should be? There are different plugins for IE - protocol plugins, some toolbars...
|
|
|
|
|
hi,
Thanks for ur reply..i want a plugin that does a specific work for IE..e.g.as google toolbar..i hope this can be created..
regards
Himanshu
|
|
|
|