|
Well...I got slightly farther. Now I'm really gonna show my lack of COM experience.
This is what I currently have, slightly tweaked from some old sample. So far, this is just a simple console application:
#include <windows.h>
#include <tchar.h>
#include <urlmon.h>
int main( void )
{
HRESULT h = CoInitialize( NULL );
if( (S_OK != h) && (S_FALSE != h) )
return -1;
IZoneIdentifier* pZI = NULL;
h = CoCreateInstance(
CLSID_PersistentZoneIdentifier,
NULL,
CLSCTX_INPROC_SERVER,
IID_IZoneIdentifier,
(LPVOID*)&pZI );
if( FAILED( h ) )
return -1;
[...]
CoUninitialize();
return 0;
}
The code compiles fine, however the linker is complaining it can't find _CLSID_PersistentZoneIdentifier and _IID_IZoneIdentifier.
The updated Platform SDK's urlmon.h defines the CLSID as:
EXTERN_C const IID CLSID_PersistentZoneIdentifier;
That's the only reference I can find on my entire hard drive. The variable is declared as extern, but not defined elsewhere...likewise, _IID_IZoneIdentifier is defined in the same file as:
EXTERN_C const IID IID_IZoneIdentifier;
Where am I supposed to find those definitions?
|
|
|
|
|
Sorry for delay, but I wasn't notified by the CP, because you replied to your reply, hence I fond it by pure coincidence )
Anyway I would expect, that from what you described, there's some .lib file required to be added to the project. I don't have the newest SDK (and as until end of week I can connect only through GPRS, I'll not have it soon) I can't tell you which one it should be, but I suspect that Urlmon.lib should do the work.
|
|
|
|
|
Thanks for following up.
I already tried linking to urlmon.lib to no avail. Lots of "unresolved externals" messages re: CLSIDs being posted on Google's Usenet archive suggest to #define INITGUID, #include <initguid.h>, add uuid.lib to the project, etc. None of these help.
I'm quickly running out of ideas...
|
|
|
|
|
I'm just downloading the new SDK, I hope I will be able to help you later today evening.
|
|
|
|
|
aghrr, once more, today's CP problems vanished my effort in writing the final response
Anyway, managed it to compile! Hooray!
I hadn't too much time for that research, but I found following:
In new updated urlmon.h the IZoneIdentifier uses the macro MIDL_INTERFACE that allows to use the brand new special microsoft __uuidof .
Problem remains with the CLSID_PersistentZoneIdentifier . Although his fellows CLSID_InternetSecurityManager and CLSID_InternetZoneManager are known and will compile, this one is obviously missing.
As I don't have too much time for the research, I just hotfixed it by adding the definition of the CLSID_PersistentZoneIdentifier by hand, before the main function in your example:
static const GUID CLSID_PersistentZoneIdentifier =
{ 0x0968E258, 0x16C7, 0x4DBA, { 0xAA, 0x86, 0x46, 0x2D, 0xD6, 0x1E, 0x31, 0xA3 } };
and the final result is then:
h = CoCreateInstance(
CLSID_PersistentZoneIdentifier,
NULL,
CLSCTX_INPROC_SERVER,
__uuidof(IZoneIdentifier),
(LPVOID*)&pZI
);
Compiles and also creates some object in return.
Hope that helps.
|
|
|
|
|
geo_m, you're my new hero.
I thought about manually adding the definition myself, but I wasn't too sure about how to proceed (again, my COM experience is limited). May I ask how you came up with that GUID?
I'll give this a shot. Thanks a million!
|
|
|
|
|
Hi,
glad that it helped. To get any GUID already registered in the system you can use the OLE/COM object view utility. This utility is a part of the VS.NET distribution and can be found also in the tools in SDK.
Here you can list all registered interfaces, objects and typelibs, with a bit of patience you can find here whatever needed )
|
|
|
|
|
> with a bit of patience you can find here whatever needed
I had everything but not that.
The OLE/COM object viewer really needs a search function...
|
|
|
|
|
Hello all,
I'm now wrting an IDL file for COM. if I want to return a vector of string, what can I do?
The method that I want is following in c++
vector<string> Function();
As far as I know, a string can be BSTR in IDL, so what in IDL corresponds to a vector or an array in C++?
Thank you very much!
|
|
|
|
|
Try SAFEARRAY.
But I think it is not recognized by MIDL compiler. Let me know if you find some other way of using arrays in IDL that MIDL recognizes.
Have a great day ahead!
Regards,
Sohail Kadiwala
(My Blog - http://blogs.wdevs.com/sohail/[^])
modified 21-Apr-21 21:01pm.
|
|
|
|
|
SAFEARRAY(BSTR) should be recognised and understood perfectly well by MIDL. I've worked on projects that made heavy use of these things, and stuff like SAFEARRAYs of user defined types
Steve S
Developer for hire
|
|
|
|
|
Hi Steve,
the MIDL compiler doesn't understand SAFEARRAY (I read it in some article). Can you lead me to some good resource/URL where more on this is shown?
Have a great day ahead!
Regards,
Sohail Kadiwala
(My Blog - http://blogs.wdevs.com/sohail/[^])
modified 21-Apr-21 21:01pm.
|
|
|
|
|
Good resource would be "Essential IDL" written by Martin Gudgin, or "Essential COM" by Don Box.
If you write
HRESULT getList([out]SAFEARRAY(BSTR)*ppsa);
in your IDL for the interface method, in your C++ you have
STDMETHOD(getList)(SAFEARRAY**ppsa);
as a definition, and
STDMETHODIMP class::getList(SAFEARRAY**ppsa)
{
...
}
as your implementation. In IDL, the array type is known (and can be a simple type, like 'long' or 'DATE', or even a user defined type (structure)).
One issue is that if you're using the MIDL that came with VC++6, you might want to upgrade by downloading the Platform SDK.
In your implementation, you need to create a SAFEARRAY, and fill in the pointer properly. There must be loads of code out there, google for "SAFEARRAY IDL SOURCE" or look here[^] for some examples of more complicated stuff...
Steve S
Developer for hire
|
|
|
|
|
Hi Steve, I am in very much need of Safearray related concepts and methodologies and its use in MIDL file.because I need much use of it too pass large values from COM Dll to VB in meterological projects and M/c related projects.Plz send me some codes and some URL where I can get get proper conceptual knowledge of SAFEARRAY with code.I'm currently facing difficulty in Passing SAFEARRAY from ATL/COM DLL to VB in an Event.So please help me.I am a memeber of this group by name Akshay Dave.My mail id is avd9683@rediffmail.com,
akshayd@eqqu.com.
Awaiting eagerly 4 ur reply.
Akshay Dave
Akshay Dave
|
|
|
|
|
|
You need to read either (or both) Essential IDL and Essential COM, or at a minimum, look for examples on MSDN and other sites (like this one) which use SAFEARRAYs. Google for SAFEARRAY SAMPLE or SAFEARRAY SOURCE which should help you get started.
Alternatively, my rates for training (if you're UK based) are quite competitive
Steve S
Developer for hire
|
|
|
|
|
hi
I would like to remote control Word. As I can insert a new tabellenzeile thank you
|
|
|
|
|
|
hi
unfortunately I find there also nothing in addition
thanks
|
|
|
|
|
(Isn't this a FAQ?)
To do this, you need to understand what parts you want to control, and know about the object model for Word. The easiest way is to record a VBA macro that does what you want, and examine it to see how it works. Often you will be able to 'optimise' the equivalent C++ code, although converting is sometimes tricky. To get you started there used to be a VBA -> C++ "conversion" tool on the MS web site (look for BTOC, I think)
Steve S
Developer for hire
|
|
|
|
|
hi steve thank you for your answer
what is this "C++ "conversion" tool on the MS web site (look for BTOC, I think)
i know it on VB, but i will it in VC++
i have no idea
|
|
|
|
|
Go to MSDN and enter 216388 in the search page. Should give 3 hits, top one B2CSE.EXE is what you want.
Steve S
Developer for hire
|
|
|
|
|
|
I want to pass array of double in an Event using Atl/Com so that the complete array must be visible in VB through that event.Awaiting for response as soon as possible.
Akhsay Dave
|
|
|
|
|
Hi !
Is it possible to take an existing MFC application and to manually add code such, that the application becomes a COM exe server ?
I found something about such a "supported addition" --> "How to Add ATL Support to an MFC EXE" http://support.microsoft.com/default.aspx?scid=kb;EN-US;175190 but it doesn't seem to work. I think that that example does't deal with COM EXE but just with plain COM.
Can anybody shed a light on this subject ?
Thanks
Roland Rubichi
|
|
|
|