1

I want to view the html content of an epub file. I dont have any problem reading and processing epub file. my problem is how to view the result HTML? I know I can use WebBrowser control in c#. but the problem is that webbrowser content can be read from external applications. I use my own DRM to encrypt and decrypt epub files. but I want to prevent copying book content from view.

I have this code (written in delphi) to get html document and content from ie control from any application:

function GetIEDocumentFromHWND(WHandle: HWND;
  var doc: IHTMLDocument2): HRESULT;
var
  hInst: HWND;
  lRes: Cardinal;
  MSG: Integer;
  pDoc: IHTMLDocument2;
  ObjectFromLresult: TObjectFromLresult;
  IE: IWebbrowser2;

begin
  hInst := LoadLibrary('Oleacc.dll');
  @ObjectFromLresult := GetProcAddress(hInst, 'ObjectFromLresult');
  if @ObjectFromLresult <> nil then begin
    try
      MSG := RegisterWindowMessage('WM_HTML_GETOBJECT');
      SendMessageTimeOut(WHandle, MSG, 0, 0, SMTO_ABORTIFHUNG, 1000, lRes);
      Result := ObjectFromLresult(lRes, IHTMLDocument2, 0, pDoc);
      doc:=pDoc;
      if Result = S_OK then
        (pDoc.parentWindow as IServiceprovider).QueryService(IWebbrowserApp,
IWebbrowser2, IE);
    finally
      FreeLibrary(hInst);
    end;
  end;
end;

this code proves that using webbrowser control is not a good solution. then what can I do?

  1. is there any way to prevent other applications from controlling my webbrowser control?
  2. is there any alternatives for webbrowser control having same power to view html ?
John Saunders
  • 160,644
  • 26
  • 247
  • 397
  • Webrowser control isn't the issue. If it was rich textbox or a pdf you'd have the same problem. Render the webcontrol's output to a bitmap would make copying far more onerous, but you lose loads of stuff that make the reading experience better. Find, book marks, skipping chapters, and critically any support for text to speech and so forth, for those with sight problems. You could reinvent all that, I could still copy your book, if I wanted to. It's on my screen. – Tony Hopkinson Mar 02 '13 at 15:09
  • What is the issue, mark text and copy paste? You can disable context menu wthin the control for disabling keyboard this may help: http://stackoverflow.com/questions/1980515/webbrowser-keyboard-shortcuts – Alina B. Mar 02 '13 at 15:22
  • no. using that code you can control the browser. it means you can get innerHTML or innerText of body elements. so you can copy all the current chapter of the book. it seems like you have that browser in your own application and you can call webbrowser methods, read content, navigate, run javascript and ... all the features are available. – Hadi Abedini Mar 02 '13 at 15:27
  • I think its not possible to access WebBrowser control( which is inside an application ) from other outside application – null1941 Mar 02 '16 at 18:49

0 Answers0