When Firefox is installed, it will ask you if you want to import data from other browsers, such as IE cookies and history. The imported code is in
Browser/components/migration/src/nsieprofilemigrator. cpp
The cookie import code is:
/* Fetch and translate the current user's cookies. <br/> return true if successful. */<br/> nsresult <br/> nsieprofilemigrator: copycookies (prbool areplace) <br/> {<br/> // ie cookies are stored in files named <username> @domain?n=.txt <br/> // (in <username>'s cookies folder. isn' t the naming redundant ?) <Br/> nsresult Rv = ns_ OK; <br/>... </P> <p> return RV; <br/>}< br/>
This part of the code is very long and I will not completely paste it here. In general, we just want to find the path where Ie saves the cookie file. If Vista enables UAC, the path is different. We also need to make judgments separately and then read the files one by one. This implementation is not perfect. Win32 already provides a ready-made API:
Handle findfirsturlcacheentry (<br/> _ in lpctstr lpszurlsearchpattern, <br/> _ out signature, <br/> _ inout lpdword lpcbcacheentryinfo <br/> ); <br/>
If the first parameter is set to "Cookie:", you can enumerate all the stored cookies. this API has been provided since Windows 2000, and Windows 2000 is also the lowest version of Windows supported by Firefox, so there is no compatibility problem.
Using a good Win32 API can often get twice the result with half the effort.