|
Hmm.. What I am trying to do is build my own version of a form designer. Do to some of the information I need to output for the form, due to its own interfaces, I need to export a form description that that contains more than a basic list of buttons and stuff. This pretty much makes any existing form designer worthless, even if I could legally include and execute it from inside my own project. While I could limit the user to known objects for which I already have the code to handle its events, set its properties or call its methods, what I really need is something that will let me do this in a true dynamic manner, so the user can opt to use controls unknown to me. I know this will only work with OLE Automation, but that is exactly the class of controls I am attempting to use.
As for OLEVIEW.EXE, this was coded in C++, so I know the there has to be some bloody way to duplicate what it does. I am not sure of either the practicality or legality of including that with my own project and I suspect it doesn't employ COM, so using it as an intermediary to select an object and read in the information I need wouldn't work anyway. I would prefer something invisible to the use, like the Components... menu in VB, where all you do is add a reference to the object and the designer handles the task of figuring out what properties, functions and events it needs to deal with when the user reloads the form file.
Basically, the project is intended to be a user definable window accessed through COM, into which they can load a form layout with their controls. The form is called from a script using the createobject method in someone elses client. To make matter more fun, do to the same stupid lack of documentation on how IE, form designers, OLEVIEW or anything else handles true dynamic object creation, where the interface *can't* be known before hand, it doesn't support a method to use such objects itself.
Nor can my using the IE core WebBrowser control do me any good. While it does provide a way to instance such controls, it does so as HTML imbedded controls that are only really accessably to its *own* scripts. I need to redirect those effects to the clients internal callbacks for it to work, since one nasty side effect of createobject is that you can't use events from the control to drive the script. I think there may be a way to drive such events from the client by linking the instance to an internal list and having it use a user defined name and the event name to redirect a call to the script (the designer of the client already does this for a few special callback where the user specifies the name to call), but this still doesn't actually solve my problem.
All in all, MS' concept of only documenting stuff they *think* we need to know about doesn't make me terribly happy... Especially when half the time the stuff they do document is scattered, confusing and incomplete.
Believe me, I am already "disappointed in the limited amount of information", from just trying to find the code to change the AmbientUserMode property. I spent 4-5 days on hunting that down before I found even a 'hint' about its use. But the general incomprehensible lack of documentation does explain why they give you an example in VB of using vbcontrolextender to capture unknown events, but somehow fail to give you a clue about how to find out what the damn things you are traping actually are... :p I wonder, are such events like small fish and animals that get caught in fishing nets? They aren't anything you can identify, so you can look at them if you like, but all you can really do with them is throw them back? lol
Seems the REFIID for a interface contains a long, two shorts and a 8 character string, so no joy there.. I had hoped it was something more useful like a simple index into the interface. So there went that idea... Sigh...
Anyway.. Thanks for trying to help.
|
|
|
|
|
Hmm.. A bit incomplete, since it doesn't provide me with any idea how to use any of the stuff retrieved, but:
http://www.geocities.com/cool_ranju/tlibs.html
I knew there had to be a way... lol Seems it helps when you look for the right search terms.
Just need to figure out which if any of these things the library lists are events and which are properties, as well as how to load and use the DLLs. Since I am actually coding the main program in VB and using C++ to impliment the stuff MS didn't think I needed to have as a DLL, this should be really fun...
And yeah, I could code it all in C++, but I figure the odds of my screwing up the code in a few classes in a DLL is a lot less than my odds of mesing up and entire program, I am an absolute newbie at C++.
|
|
|
|
|
Hello.
I've got a problem. I use automation in my custom COM object(which is created using JavaScript on a page) to open MS Project from a secured zone on a web site. Assuming user has logged on, using FileOpen method of Application object leads to another prompt for user to log in.
Here's the code snippet off my COM:
......................
CComDispatchDriver app;
app.CoCreateInstance(L"MSProject.Application);
CComVariant arg1 = FileName; //URL of the MS Project file passed from
//JavaScript to my COM; BSTR
CComVariant arg2 = VARIANT_TRUE; // Read-only mode.
app.Invoke2(L"FileOpen", &arg1, &arg2);
.......................................
That worked fine except for the need to login for the second time upon my COM trying to open file. After second authorization COM proceeded with its job.
First solution was to use URLDounloadToFile() function to download the file to the temporary local directory and then give it to the FileOpen. That worked perfectly, no need to authorize again, BUT
it's considered as a potential SECURITY HOLE.
So the second solution is to try to use URLOpenBlokingStream to actually open the stream of my URL and then somehow give it to the MS Project.
But I don't have an idea how to give IStream to the MS Project to open it.
Any suggestions would be highly appreciated
|
|
|
|
|
Hello everyone.
I want to hook file operation to move, copy, delete, or rename a file.
I found ICopyHook interface, But it was only possible hooking folder operation.
Isn't there any good method?
with regards,
kona
|
|
|
|
|
"the vaue of ESP was not properly saved across a function call" got this error Dialog while compiling an empty MFC client, with a ATL control added to the UI. the ATL control is empty too, no implementations at all.
help?
|
|
|
|
|
Recompile the component and the client this should work, mostly it is due to incorrect parameter passing from the client.
Still Alive!!!
Thank you God.
|
|
|
|
|
thank you for the suggestion but it din't work. is there a bug in VC++ with regards to importing a ATL Control into MFC client? i have no methods in the ATL control yet hence there can't paraemeter passing involved cept for those that are carried out in the background..
|
|
|
|
|
The error you describe typically occurs when there is a calling convention clash between caller and callee. For instance, class member functions are typically _thiscall, while other C++ functions are __stdcall, and C functions are _cdecl.
Some routines, particularly callbacks should be __stdcall, but occasionally, you'll see something like qsort, which requires that the ordering function you give it be __cdecl.
Are you overriding the default calling convention of any of your functions?
The other alternative, of course, is that you're overwriting the stack (in a subtle way, generally). If you know the function call, you can put a breakpoint on entry, then display the call stack, and step through the function until you see the call stack get hosed...
Steve S
|
|
|
|
|
apparently the problem is with the compiling computer. it works fine in other computers. i tried installing MS SDK, VC++ SP5, clearing up the registry... and nothing works.. haha.. will be installing a new copy of VC++ today.. thanks for all the help guys. BUnch of great ppl we have here!!!
|
|
|
|
|
Hi all,
I want to find an utility that do something like that:
Takes TLB (or whatever) and generates C++ wrapper classes for use these COM interfaces/objects. With ATL it could looking like:
IDL:
interface ITest
{
HRESULT GetName([out,retval] BSTR *bstrName);
HRESULT DoSmth([in] BSTR str);
}
C++ (ATL) Wrapper:
class CTest : public CComPtr<ITest>
{
public:
CString getName()
{
CComBSTR bstr;
HRESULT hr = p->GetName(&bstr);
if (FAILED(hr))
throw hr;
return CString(bstr);
}
HRESULT doSmth(LPCTSTR str)
{
return p->DoSmth(CComBSTR(str));
}
}
Such wrappers allows to program COM in C++ much easier, almost like in VB, at the same time preserving all C++ power.
Does anyone knows something similar ?
Thanks in advance,
vips
|
|
|
|
|
The #import directive already does this for you automatically.
|
|
|
|
|
Thank you for fast reply.
I'll try to discover the #import behavoir in C++.
|
|
|
|
|
you can also use MIDL <file.idl> /h file.h
to get an IDL file you can use oleview
|
|
|
|
|
Hi Guys,
Can somebody tell me whether COM objects are stateless or stateful ?
AS far as i understand, State of an object is defined by the data member it contains and COM objects can have data members.
BIG_MG
|
|
|
|
|
COM objects are stateful. The very notion of object in OOP is a black box with some state, which is observed and manipulated using its public operations.
An object which is not stateful, is not an object.
--
So let's just walk from place to place, as long as we don't talk face to face.
|
|
|
|
|
We've turned our application into a DCOM automation server, which works well. The problem we have is that we need this application to execute once per client, and we need the app to run as a certain user. If I log on to the server machine as this user, and have the applications identity set to 'interactive user' in dcomcnfg.exe, everything works well. If I use 'this user' however (regardless of being logged on as that user) the application launches and functions properly twice (concurrently), but no more then twice.
When I debug into the third instance, I find that it is unable to load the main frame, it actually falls over in CMDIFrameWnd::CreateClient and GetLastError returns 'invalid window handle'.
Has anyone got any idea what is happening here, or could you point me in the right direction for more information?
Dylan
|
|
|
|
|
I have a com object in which there are different properties. When i get these values through it works well when property is returning long or some other integer but it crashes when property is returning bstr. Take a look at my code and guide me that what i did wrong.
VARIANT pvResult;
memset(&pvResult, 0, sizeof pvResult);
VariantInit(&pvResult);
DISPID dispID=this->pColl->getMemberID(index);
DISPPARAMS dispParamsNoArgs={NULL,NULL,0,0};
HRESULT hr=pDispatch->Invoke(dispID,IID_NULL,LOCALE_USER_DEFAULT,
DISPATCH_PROPERTYGET,&dispParamsNoArgs,
&pvResult,NULL,&nArgErr);
Thanx in advance
Inam
|
|
|
|
|
u have forgotten the last line
return pvResult.bstrval;
(offcourse after making your method of the type returning bstr)
and if u already have it there in your code..then take a look at the following code, also if it doenot work then try looking into the dispatch map..have u given the correct VTs there for the return type??
//*******************************
//body of a method returning BSTR
DISPPARAMS * DispParam1 = new DISPPARAMS();
EXCEPINFO excep;
UINT nArgErr;
VARIANT *pVarRes = new VARIANT();
DispParam1->cArgs = 0; //number of arguments
DispParam1->cNamedArgs = 0;// Number of named arguments.
DispParam1->rgdispidNamedArgs = NULL; // Dispatch IDs of named arguments.
IF1BookImpl::Invoke(DISPID_F1_Text,
IID_NULL ,
::GetUserDefaultLCID(),
DISPATCH_PROPERTYGET,
DispParam1,
pVarRes ,
&excep,
&nArgErr);
delete DispParam1;
return pVarRes->bstrVal;
//*******************************
regards
safee
|
|
|
|
|
Infact program crashes when it executes the function invoke and in pVarRes there is coming bstr through get property but if long or int is coming it works well.
Now i am not understanding what to do
Regards
minamkhan
Inam
|
|
|
|
|
Try
VARIANT *pVarRes = new VARIANT();
V_VT(pVarRes) = VT_BSTR;
and see if that helps....
Steve S
|
|
|
|
|
Hi. I was using Inside COM by Dale Rogerson book and I dont have the CD, so I kinda guess how to register the component.
But when I do "regsvr32 /s Cmpnt.dll" , the entry for "InprocServer32" is garbage.
Can someone help me out with this?
Registry.cpp:
#include <atlbase.h>
extern "C" HRESULT RegisterServer(HMODULE g_hModule,
const CLSID& CLSID_Component1,
const char* g_szFriendlyName,
const char* g_szVerIndProgID,
const char* g_szProgID)
{
CComModule cm;
return cm.RegisterClassHelper(CLSID_Component1, g_szProgID, g_szVerIndProgID, NULL, THREADFLAGS_BOTH);
}
cmpnt.def:
;
; Cmpnt1 module-definiteion file
;
LIBRARY Cmpnt.dll
DESCRIPTION '(c)1996-1997 Dale E. Rogerson'
EXPORTS
DllCanUnloadNow @1 PRIVATE
DllGetClassObject @2 PRIVATE
DllRegisterServer @3 PRIVATE
DllUnregisterServer @4 PRIVATE
DllMain @5 PRIVATE
|
|
|
|
|
Please tell me whether it is possible to finalize CD using IMAPI interface.
Thanks,
Igor.
|
|
|
|
|
wt actually working of queryinterface function?
sdfsdfsdfhsdfh
|
|
|
|
|
QueryInterface is a discovery mechanism. Let's say you have an interface (any interface, it doesn't matter) to a COM component. You can, using a method in the interface, ask the component if it supports another interface that you know about.
For instance, you might have an IFrooble interface on an object, and you want to know if it supports automation using the 'classic IDispatch' method.
You say something like:
HRESULT hr;
IDispatch* pDisp = NULL;
hr = pFrooble->QueryInterface( IID_IDispatch, reinterpret_cast<void**>(&pDisp));
if (SUCCEEDED(hr))
{
// Yep, it does dispatch, and we now have that interface as well
// as the IFrooble one.
}
else
{
// No, it doesn't or can't provide that interface
}
Does that help?
Another scenario is versioned interfaces, where a client will ask for successive interfaces (eg IFooBar4, IFooBar3, IFooBar2, IFooBar) until it gets one it's happy with.
Steve S
|
|
|
|
|
If you look from the C++ point of view,
All you interfaces to COM object are abstract base classes with pure virtual functions. And your COM object gives implementation of all these functions.
So when you call QueryInterface, it simple casts the COM object(this) into the interface pointer, increase a reference count and return that pointer. This way you can only call the functions declared in that interface.
|
|
|
|
|