Which is why I've been trying to get Catalyst to understand that in a separate thread. I mean, if you can't even understand environment variables, why would anyway think to tackle COM? That's like trying to climb Everest or K2 without making it up the front steps to the lobby (if it has one?)!
If you want to do things this way, you must create an IDL file (don't use headers and don't worry about compiling to a DLL) and import additional IDL files when necessary. Interface documentation should list what IDL file they are found in. If not, check for a similar IDL file that matches the name of the header file (filename.h to filename.idl).
Heath Stewart wrote: Take a look at the following CP article which gives an example of how to go from IDL files -> midl.exe -> typelib -> tlbimp.exe -> interop assembly: Using MSHTML Advanced Hosting Interfaces[^].
You beat me to it, I was looking for the link to that article to post a reply and thought I would check to see if you had posted a reply yet.
First, add the paths to your INCLUDE enviroment variable and you won't have to worry about paths.
Second, no, you shouldn't include the interface information - they're already defined you're just forward-defining them.
There's plenty of information about IDL in the PSDK. You should read some of that. Also, just do what the author did in the article that I linked. He does everything you need to do, just with different IDL files, interfaces, and structs.
You've never done any C/C++? The INCLUDE environment variable is a user- or system-environment variable that includes a semi-colon delimited list (colon-delimited in *nix) of directories where header files (or, in this case, IDL files) are located. You can set this in VS, too, but then it only applies to the VS environment instead of all applications (if an application is open, you'll have to restart it after setting the env. var.).
This is the extent? COM is by no means an easy subject and Windows shell programming gets even harder (since it uses COM and adds certain complexities). You really should spend some time learning the basics. Learning things as you go is always good and you should never stop, but you have to have experience upon which to build.
Right, I have found the INCLUDE setup in my Enviroment variables of System Properties.
I have added the following entries to my INCLUDE section in the System Variables:
"F:\MSDN\SDK\v1.1\include\; F:\MSDN\Vc7\include; F:\MSDN\Vc7\PlatformSDK\Include"
Now, it appears that MSDN is NOT my VS directory, and i'm not sure if this is correct, but it contains all the include information of the PlatformSDK.
Now, i am not sure if this is actualy working, as i still gain no joy with the objidl.idl, which is in the directory "F:\MSDN\Vc7\PlatformSDK\Include".
Not sure what's wrong there.
I know Heath. I am going through the COM tutorials at the moment. I'm more than happy to take a step away from where I am in order to learn background knowledge, and since i've hit this whole DragDrop thing, i've learned a reasonable amout about C and COM from reading articles and experimenting with sample code.
It's actualy quite fun
I will continue on with these tutorials, but I think my next step would be to get my tools working. Midl and TblImp.
Never mind, i had a problem with not running vcv*something*.bat. It appears to be all working now.
Although, midl does not appear to be generating the objidl.tlb file I asked it to, despite running without errors.
Don't include spaces between delimited directories in your INCLUDE env. var. (or PATH, LIB, or any other delimited path env. vars. like that). Also keep in mind that you can use env. vars. even in those env. vars. by defining things like PSDK=F:\MSDN\Vc7\PlatformSDK as another env. var., then using INCLUDE=%PSDK%\Include.
Also, you should download the newest PSDK from MSDN. If you're using the one in your VS.NET directory, you're using an OLD one. Also, don't include directories in your env. var. in quotes. That is one thing that the OS will handle correctly when using the UI. When doing this in a command line, you would have to type it like so:
set INCLUDE=C:\SomeDir;C:\SomeDir\Some Other Dir
Make sure there's no space around the equals (=) sign and don't use quoes there, either. Also note that typing this in the command prompt only makes the INCLUDE env. var. durable for THAT particular command prompt instance. You can also append directories like so:
set INCLUDE=%INCLUDE%;C:\SomeDir;C:\SomeDir\Some Other Dir
Again, if you change the env. vars. through the Advanced tab in the system properties, you must restart any program - including the command prompt - in which you need these changes reflected (for instance, an open Internet Explorer browser window won't benefit from this change, so you don't have to restart it).
Note also that VS.NET maintains it's own list, though there is ways to make it use the system and user environment variables instead. See the Options for details and just try it out.
You're not supposed to compile the whole thing to a typelib, only forward-define the interfaces in your own IDL file and then compile that to a typelib. See the midl.exe documentation for more command-line options. Each IDL file doesn't have a typelib because many are typically meant to be included in other IDL files while being defined in a library elsewhere - this isn't your concern. Do what the linked article I gave you mentions and generate a typelib including the interfaces, structs, and enums you need ONLY. Anymore - unless you're planning on interop'ing the whole COM for a huge-ars library - is just overkill and bloat.