Link to home
Start Free TrialLog in
Avatar of pingle
pingle

asked on

Direct File manipulation

Hello,
   I need to search directly for different records within a file in its actual location...as basically as possible.  Does anyone have any suggestions for me?
Thanks
Avatar of jkr
jkr
Flag of Germany image

See http://support.microsoft.com/support/kb/articles/Q292/4/85.ASP ('HOWTO: Programmatically Save an HTML Page to Disk'). The scoop is:

Accomplishing this task from a Visual C++ host is very straightforward. You can use an IWebBrowser2
interface to call the QueryInterface method for the IHTMLDocument2 interface. After you obtain a pointer
to the document, then call QueryInterface for the IPersistFile interface. After you obtain this interface
pointer, you can call the save method to save the file to disk.

   HRESULT          hr    = E_FAIL;
   IDispatch*       pDisp = NULL;
   IHTMLDocument2*  pDoc  = NULL;
   
   pDisp                  = m_webOC.GetDocument();

  if(SUCCEEDED(hr = pDisp->QueryInterface(IID_IHTMLDocument2,(void**)&pDoc)))
  {
      IPersistFile*     pFile     =     NULL;
      if(SUCCEEDED(pDoc->QueryInterface(IID_IPersistFile,(void**)&pFile)))
      {
    LPCOLESTR     file = L"c:\\test1.htm";
    pFile->Save(file,TRUE);
      }
  }
Ooops, sorry, wrong browser window :o)
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you're running on a Windows platform, you can do a MapView, and get a (void*) pointer to the data in the file.
You can then use regular C++ functions to manipulation the data in the file.
FYI:
You can also do MapView from unix using mmap and munmap functions.