devxlogo

April 25, 2001

How to Share a Handle Between Two Threads

Whenever a handle is passed to another thread, use the DuplicateHandle API to create a duplicate handle to the same object and pass this duplicated handle to the thread. That

Determine Current User

In Windows, the computer can be set up so that many different users can log into the computer. The current user

Use Mid$ to Compose a Big String

The following code is a fast way to compose a big string by using Mid$ function instead of using the concatenating operator. The strings concatenated in a loop are often

CString – IPAddress(DWORD) Conversion for CIPAddressCtrl

The following method returns a (DWORD)IPAddress from a(CString)IPAddress. It is quite useful when using the CIPAddressControl. DWORD CMyClass::GetDWORDIPAddress(CString strIPAddress){ strIPAddress.MakeReverse();// Start from behind char DOT = ‘.’; DWORD dwReturnValue =

How to Force a C++ Class to Be a Singleton

The following example demonstrates how to have only one instance of a class at a time. class MySingleTon{public: static MySingleTon * GetObject() { static MySingleTon obj; return &obj; } …