January 25, 2008

How to initialize static member variable?

class X
{
public:
    static int i;
};
int X::i = 0; // definition outside class declaration

January 24, 2008

Notes for QueryFilterInfo()

FILTER_INFO Info = {0};
pFilter->QueryFilterInfo(&Info);
if(Info.pGraph != NULL)
    Info.pGraph->Release(); // You MUST release here

January 19, 2008

Microsoft Win32 to Microsoft .NET Framework API Map

Microsoft Win32 to Microsoft .NET Framework API Map
http://msdn2.microsoft.com/en-us/library/aa302340.aspx

This is a very useful article for C# programmer.

January 17, 2008

Notes for writing DLL in which use STL objects

You may experience an access violation when you access an STL object through a pointer or reference in a different DLL or EXE.

Root Cause:
Since the static data members in the executable images are not in sync, this action could result in an access violation or data may appear to be lost or corrupted.

Suggestion:
Avoid using STL object as the parameter or the return value of an exported DLL function.

MSDN Reference:

January 10, 2008

Notes for HttpWebResponse class

You MUST call Close method to close the response and release the connection.

HttpWebRequest HttpWReq = (HttpWebRequest)WebRequest.Create("http://www.google.com");

HttpWebResponse HttpWResp = (HttpWebResponse)HttpWReq.GetResponse();
// Insert code that uses the response object.
HttpWResp.Close();

http://msdn2.microsoft.com/en-us/library/system.net.httpwebresponse.aspx

January 01, 2008

Notes for to remove certain filter from a graph

You should check that the graph is stopped or it will fail to remove any filter.