Hacking Outlook Express - COM Interop |
Written by Mike James | ||||||
Thursday, 23 July 2009 | ||||||
Page 3 of 5
Exposing COMNow that everything is initialised we can add a method to the OE class that exposes the other COM functions, for example, GetDirectory. This returns the directory where all of the OE folders are stored and a class method to make use of it is simply defined: public string getDirectory() If you now put a button on the project’s form and add the code: OE oe = new OE(); you will see the location of the OE root directory displayed in a message box. Creating, moving and renamingFinding out where the OE root directory is proof that the project is working but for something more useful we need to continue the definition of the Interface. Add the following function definitions to the Interface, again obtained by translating the details in the header file: void OpenSpecialFolder( void OpenFolder( void CreateFolder( void RenameFolder( void MoveFolder( void DeleteFolder( The most useful of these at this stage are CreateFolder, RenameFolder, MoveFolder and DeleteFolder. These can be added as methods to the .NET class as: public Int32 createFolder( public void renameFolder( public void moveFolder( public void deleteFolder( To demonstrate how these work we can now create a new folder called “test” in the root (folder Id 0) Int32 id=oe.createFolder(0, "test"); Move the folder to folder Id 4: oe.moveFolder(id, 4); Rename the folder to “newname” oe.renameFolder(id, "newname"); Delete the folder: oe.deleteFolder(id); As deleting a folder simply moves it to the “Deleted Folder” we can delete it a second time to get rid of it permanently: oe.deleteFolder(id); <ASIN:0735624240> <ASIN:0735618755> <ASIN:0321440307> |
||||||
Last Updated ( Wednesday, 16 September 2009 ) |