

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Instructions for building an in-process distributed object project from scratch using visual c++. It covers creating a workspace, setting up console app and win32 dll projects, modifying idl files, and implementing classes. Students in the cse791 – distributed objects course will find this guide helpful for understanding the process of creating com components.
Typology: Study Guides, Projects, Research
1 / 2
This page cannot be seen from the preview
Don't miss anything!
Assumes you are creating a new workspace and project but modifying files from an existing in-proc project
1. Copy all inproc1_Ex1 files to your work folder. 2. Throw away all project, and workspace files. you will often keep the project files and simply insert them into the new workspace, but I will describe how to rebuild them all. 3. Open VC++ IDE and create a workspace – say myInproc. 4. Create a console app project for client and a Win32 DLL project for component. 5. In the component project select Project\Settings\C/C++\Category:\Code Generation and in the Use run-time library: comboBox select Debug Multithreaded DLL. 6. Make sure MkTypLib compatible option in Project\Settings\MIDL is not checked. 7. Add cmpnt.idl, cmpnt.cpp, cmpnt.def, registry.h and registry.cpp to component. 8. Add client.cpp to client. 9. Build the component and client as described on the next page. Do this first and make sure that the client runs successfully before you start modifying anything!
10. Bring up the idl file in the IDE by clicking on it in the FileView. 11. Give the IDL interface and coclass names suitable for the current project and make whatever changes are required to the interface definition(s). Also modify the manual and maintenance comments as appropriate. 12. Change the IDL helpstrings to match current project. 13. Replace GUIDs in IDL with new ones generated by GUIDGEN – I have added c:\program files
Microsoft Visual Studio\Common\tools\GUIDGEN to my tools list in IDE with the Tools\Customize option. This is important – don’t skip it. 14. Run MIDL cmpnt.idl from command line first time to generate files to add to client and component. 15. Add cmpnt_i.c and cmpnt.h (created by MIDL) to the client and component projects.
16. Now modify cmpnt.cpp implementation to suit the processing needs of your project. 17. Replace friendly name of component, ProgID, and version independent ProgID at top of cmpnt.cpp with your own strings. 18. Also change the component’s QueryInterface function to support the new interface. All you do here is to change the IID_IString to IID_IYourInterface. 19. Modify function DllGetClassObject(…), near the bottom of cmpnt.cpp. You change CLSID_inproc1_Ex1 to CLSID_YourProject. If you are not sure what the CLSID is, check cmpnt.h after you have run MIDL on your IDL file(s). This file is generated by MIDL from your IDL file. Toward the bottom you will find the CLSID declared. Use that. 20. Change dll name in library description in cmpnt.def to match your project name. 21. Modify the component class to implement your interface – for this example you change class declaration to match your interface changes. You will be adding functions to interact with the xmlParser. It is wise, at this step, to rebuild after every change, even small changes! 22. Modify client to use new interface (see client.cpp).
23. You don’t need to change registry.h or registry.cpp. The registration process is always the same. It simply uses the file path\name returned by GetModuleFileName, using the module handle, the CLSID it gets from cmpnt.h and the ProgIDs provided at the beginning of cmpnt.cpp.
1. Go to Windows Start\Run and type cmd. This will open a DOS window. Navigate to your project directory and type dir *.idl/s. For each idl file in your project navigate to that directory (if different from the top level directory) and type MIDL idl_fileName.idl^1. This will generate new files to define the abstract interface and GUIDs for your project. 2. Rebuild the component and client as described in the previous section. Before running do the next step. 3. Navigate to the top project directory and type dir *.dll/s. For each dll you find, navigate to that directory and type regsvr32 dll_fileName.dll^1. This will register the dll component. What you have just done is to manually compile the IDL files and manually register the controls in your project. Usually you don’t have to do this, but sometimes you have to help the IDE. (^1) Here idl_fileName and dll_fileName are the names of the files you find with the dir command.