Posts

Reflection API to access COM objects sample

quoted from URL Object o; System.Type t = Type.GetTypeFromProgID("MODI.Document"); o = System.Activator.CreateInstance(t); Object[] a = new Object[1]; a[0] = "C:\\Temp\\iri36300.TIF"; t.InvokeMember("Create", BindingFlags.InvokeMethod, null, o, a); Object images = t.InvokeMember( "Images", BindingFlags.GetProperty, null, o, new Object[] {} ); Type imagesType = images.GetType(); Object item = imagesType.InvokeMember( "Item", BindingFlags.GetProperty, null, images, new Object[] {"0"} ); Type itemType = item.GetType(); itemType.InvokeMember("OCR", BindingFlags.InvokeMethod, null, item, new Object[] { 9 } ); Object layout = itemType.InvokeMember("Layout", BindingFlags.GetProperty, null, item, new Object[] {} ); Type layoutType = layout.GetType(); Object ocrResult = layoutType.InvokeMember( "Text", BindingFlags.GetProperty, null, layout, ...

Locating MAPI directory using FGetComponentPath

Codes below quoted from URL By Sam Charchian typedef BOOL (STDAPICALLTYPE FGETCOMPONENTPATH) (LPSTR szComponent, LPSTR szQualifier, LPSTR szDllPath, DWORD cchBufferSize, BOOL fInstall); typedef FGETCOMPONENTPATH FAR * LPFGETCOMPONENTPATH; static TCHAR s_szMSIApplicationLCID[] = "Microsoft\\Office\\9.0\\Outlook\0LastUILanguage\0"; // STRING_OK static TCHAR s_szMSIOfficeLCID[] = "Microsoft\\Office\\9.0\\Common\\LanguageResources\0UILanguage\0InstallLangu age\0"; // STRING_OK //////////////////////////////////////////////////////////////////////////// /// // Function name : CSVCFile::InitMAPIDir // Description : For Outlook 2000 compliance. This will get the correct path to the // : MAPISVC.INF file. // Return type : void // Argument : LPSTR szMAPIDir - Buffer to hold the path to the MAPISVC file. void CSVCFile::InitMAPIDir(LPTSTR szMAPIDir) { ...

Troubleshooting Outlook Express (IMAP, POP3, HTTP, NEWS) with the log file

Just happen to know this when trying to solve my friend OE problem. You can log in POP3, IMAP, NEWS, HTTP commands of your Outlook Express into a log file. (note, the password in the log file is encrypted by Microsoft, therefore, it is safe to ask user to send the log file over if you are a IT support) To enable logging. ------------------------- Tools(menu) - Options (menu) - Maintenance(menu) - check on the protocol you need. (POP3, IMAP, NEWS or HTTP) To view the log file -------------------------- Goto path C:\Documents and Settings\YourUserName\Local Settings\Application Data\Identities\{8D32DF8B-D3B8-4783-A0C5-FE37E2FC8659}\Microsoft\Outlook Express\pop3.log (for pop3) imap.log for (imap) and other respectively. P.S. The {8D32DF8B-D3B8-4783-A0C5-FE37E2FC8659} may vary and there could be a few Identities in it. Look for the folder with the structure of *.dbx similar to your Outlook Express email account.

Steps to set up VS.NET 2003 remote debugger

(quoted from http://www.codecomments.com/archive370-2005-2-396392.html) msvcmon ( Visual C++ .NET 2003 ) on Windows 9x/NT 4.0/2k/XP. Steps to set up the remote debugger 1. copy msvcmon.exe and all the dll it needs to the target machine ( Windows NT4.0 SP6). Psapi.dll need to be copied over Winnt\System32. 2. on the target machine, open a DOS command windows c:\app\msvcmon -anyuser 3. start the app ( of course the debug version ) on the target machine 4. on the development machine ( Windows XP SP2 ) , open the project file, go to Debug -> Processes select "TCP/IP(native only)" as the transport layer, and type the IP address of the target machine. Then click "refresh" button. (use PSList or PSKill for remotely terminate process. (at sysinternals.com)) URL for explanation on its usage.

Outlook : "operation failed, object could not be found. " when trying to close a PST.

Image
When you try to close a PST. The error message "operation failed, object could not be found" pop up. After you have tried scanpst and detect and repair. Still won't work. Solution. (a hard way) Start Regedit Go to Key HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Microsoft Outlook Internet Settings Where "Microsoft Outlook Internet Settings" is the Outlook profile name that has problem. (note: Outlook support multiple profile even for same Windows login) In the HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Microsoft Outlook Internet Settings, you will see a bunch of long string sub keys in it Like in the format of GUID, like e.g. 75d1fa940a0d3a4497130516edbde90e Then, start at the very first sub keys of HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Microsoft Outlook Internet Settings. Right click on sub key, Select Find (menu) And then, ...

error LNK2001: unresolved external symbol _IID_IMessage

Often time, I encounter unresolved external symbol _IID_IMessage problem when I am trying to use IID_IMessage in my codes. This is my solution to the problem, include and define in such sequence. #define INITGUID #define USES_IID_IMessage #define USES_IID_IMAPIPropData #define USES_IID_IMAPITable #include <initguid.h> //this is needed, #include <mapiguid.h> //then this #include <mapiform.h> #include <objbase.h> #include <mapix.h> #include <mapitags.h> #include <mapidefs.h> #include <mapiutil.h> #include <imessage.h>

Managed string to Unmanaged string

Taken from http://www.cs.virginia.edu/~cs216/labs/helpdocs/system.string.html Example Code #include "stdafx.h" #include #include using namespace std; #using using namespace System; using namespace System::Text; using namespace System::Runtime::InteropServices; //Converts a System::String to a std::string //This code assumes that you have used the following namespace: // using namespace System::Runtime::InteropServices; std::string ManagedToSTL(System::String *managed) { //get a pointer to an array of ANSI chars char *chars = (char*) Marshal::StringToHGlobalAnsi(managed).ToPointer(); //assign the array to an STL string std::string stl = chars; //free the memory used by the array //since the array is not managed, it will not be claimed by the garbage collector Marshal::FreeHGlobal(chars); return stl; } //Converts a std::string to a System::String //This code assumes that ...

IT conversation

http://www.itconversations.com/ Listener-supported audio programs, interviews and important events.

Viewing STL container in VS.NET 2003 watch windows

For a vector, you can start with these examples: "v._Myfirst" -> the first element "v._Myfirst, 10" -> 10 elements "v._Myfirst[1]" -> the element at index 1 "v.size()" -> number of elements For a list: "l._Mysize" -> number of elements "l._Myhead->_Next->_Myval" -> the first element "l._Myhead->_Next->_Next->_Myval" -> the second element "l._Myhead->_Next->_Next->_Next->_Myval" -> the third element, etc.

MFC Windows Message Processing - yield control

(Refering Programming Ms Visual C++ fifth edition - Ms Press) A workaround which works with both Win16 and Win32. Yield control once in a while by inserting the following instructions inside the time consuming function: MSG message; if (::PeekMessage(&message, NULL, 0, 0, PM_REMOVE)) { ::TranslateMessage(&message); ::DispatchMessage(&message); } The PeekMessage function works like GetMessage , except that it returns immediately even if no message has arrived for your program. In that case, the function keeps on processing. If there is a message, however, the function pauses, the handler is called, and the function starts up again after the handler exits. E.g. void CMyClass::LengthyFunction() { MSG message; volatile int nTemp; for (m_nCount = 0; m_nCount for (nTemp = 0; nTemp // processing here. } if (::PeekMessage(&message, NULL, 0, 0, PM_REMOVE)) { ::TranslateMessage(&message); ::D...

Recover HDD after format

SystemRescueCd is an improvement of the gentoo live cd. It aims to provide an high quality bootable CD-Rom, with all system utilities that can be required to repair your system. http://sourceforge.net/projects/systemrescuecd There seems to be some utilities for FAT16/32 ( dosfstools [ ^ ]) and NTSF ( NTSFProgs [ ^ ]) included on the bootable linux CD There is also this tool R-Studio 2.0 [ ^ ] http://www.grc.com/sr/spinrite.htm [ ^ ]

Merging menu items for MDI container and MDI child forms

Say, if MDI container has a "About" Menu that the MDI child forms need to merge with. Set the MDI container menu in such manner. (In the InitializeComponent or change it using the IDE property window) this.menuItemAbout.Index = 1; this.menuItemAbout.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.menuItemMainHelp}); this.menuItemAbout.MergeOrder = 1; this.menuItemAbout.MergeType = System.Windows.Forms.MenuMerge.MergeItems; this.menuItemAbout.Text = "Help"; this.menuItemMainHelp.Index = 0; this.menuItemMainHelp.MergeOrder = 1000; //this need to be larger than the child so that it appear //underneath the child menu items. this.menuItemMainHelp.Text = ...

Integrate help to .NET apps

Help.ShowPopup(this, "Enter Phone number here. Valid input characters are 0-9,space,'-','(', and ')'", Cursor.Position); //this will show an unconventional popup message box on the cursor position. Nicer than standard //messagebox Can also use the HelpProvider object HelpString properties to achieve the same effect but seems to have less control over. when drag a System.Windows.Forms.HelpProvider to a form. All the controls in the form will have the option HelpNavigator on myHelpProvider avail in the properties windows. For directing the F1 key press to index of the CHM. The helpprovider need to set HelpNamespace to "Help\VB.chm" (to chm appropriate). Then, in the needed control, HelpNavigator on myHelpProvider option, choose keyword index, and then key in the helpkeyword. This will automatically map the F1 key press or the "?" help button button to be directed to the CHM.

To sort using ArrayList.Sort()

Quoted from http://www.codeproject.com/useritems/sortingarraylist.asp public struct MyStrcuture { public Int32 iID; public String sName; } In order to be able to sort elements contained in an ArrayList , we have to define the CompareTo method of the IComparable interface, and then use the ArrayList's .Sort() method. This -of course- means that our structure should be inherited from that interface .. and so we'll do! public struct MyStrcuture : IComparable { public Int32 iID; public String sName; public Int32 CompareTo(Object obj) { MyStrcuture tmpObj = (MyStrcuture) obj; return ( this .sName.CompareTo(tmpObj.sName)); } } This would allow the array list to be sorted by just calling MyArrayList.Sort() provided the arraylist containing the item with the above structure. Useful sorting algorithms in C#. URL

Useful C++ code snippet (ascii to unicode)

void ascii2unicode(LPCTSTR strin, wchar_t* strout) { int len = strlen(strin); for(int i=0; i<len; i++) strout[i]=(wchar_t)strin[i]; strout[i] = 0; }

ImpLib32

http://www.geocities.com/SiliconValley/5806/implib32.htm ImpLib32 is a small utility which creates an import library for Visual C++ 2.x/4.x/5.x from an existing DLL. What is Implib32: Implib32 creates 32 bit import libraries for the use with Microsoft Visual C++ 2.x/4.x/5.x. Back in the good old days of Windows 3.x, Microsoft supplied a tool called IMPLIB. This tool was able to create a import library for a given DLL. After creating this library, you linked it to your program in order to call functions contained in the DLL. Unfortunatly, there is no equivalent to IMPLIB for Win32. Microsoft suggests on the Win32 Knowledge Base that you should use DUMPBIN to create a file which lists all exports of a DLL, reformat this file to .DEF-file using a text editor and then use LIB to create a import library from the .DEF-file. Implib32 does all this work for you: It invokes DUMPBIN and LIB and creates an import library! Note: ImpLib32 can't process...

Open Source Licensing Quick Guide

(quoted from http://zooko.com/license_quick_ref.html ) QUICK REFERENCE FOR CHOOSING A FREE SOFTWARE LICENSE, version 1.4.5.0, 2004-08-31 License | hackers like to accept code under it | | combine with proprietary and redistribute | | | combine with GPL'ed code and redistribute | | | | must share source of redistributed version | | | | | must include patent license with contribution | | | | | | | | | | | | v v v v v v --- --- --- --- --- --- permissive Y Y Y N N GNU LGPL Y2 Y1 Y Y Y GNU GPL ?2 N Y Y Y Mozilla PL 1.1 Y2 Y N3 Y Y (FAQ on MPL URL ) Excel doc which explains various licensing stuff http://www.mass.gov/itd/legal/quickrefchart.xls

The Robots Exclusion Standard (web spider)

http://www.searchengineworld.com/robots/robots_tutorial.htm http://www.searchengineworld.com/cgi-bin/robotcheck.cgi Getting more hits count for a web sites. http://tom.gilki.org/programming/other/121104/ and set the meta tag of the main page. (check thestar.com.my)

C++: Named Constructor Idiom

(quoted from http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.4 ) What is the "Named Constructor Idiom"? A technique that provides more intuitive and/or safer construction operations for users of your class. The problem is that constructors always have the same name as the class. Therefore the only way to differentiate between the various constructors of a class is by the parameter list. But if there are lots of constructors, the differences between them become somewhat subtle and error prone. With the Named Constructor Idiom, you declare all the class's constructors in the private or protected sections, and you provide public static methods that return an object. These static methods are the so-called "Named Constructors." In general there is one such static method for each different way to construct an object. For example, suppose we are building a Point class that represents a position on the X-Y plane. Turns out there a...

C++: Warning: Derived::f(char) hides Base::f(double)

(quoted from http://www.parashift.com/c++-faq-lite/strange-inheritance.html ) What's the meaning of, Warning: Derived::f(char) hides Base::f(double) ? Updated! [Recently included a new example, changed the parameter types so the behavior seems more bizarre/ominous, and added a note about warnings not being standardized, thanks to Daniel Kabs (in 12/04). Click here to go to the next FAQ in the "chain" of recent changes .] It means you're going to die. Here's the mess you're in: if Base declares a member function f(double x) , and Derived declares a member function f(char c) (same name but different parameter types and/or constness), then the Base f(double x) is "hidden" rather than "overloaded" or "overridden" (even if the Base f(double x) is virtual ). class Base { public: void f(double x); ← doesn't matter whether or not this is virtual }; class Derived : public Base { pu...