Genilto Dallo
Решение найдено в: https://itproblemy.pl/questions/23248740/how-to-disable-url-detection-idmautourldetectmode-in-windows-forms-webbrowser-control
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct OLECMDTEXT
{
public uint cmdtextf;
public uint cwActual;
public uint cwBuf;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 100)]
public char rgwz;
}
[StructLayout(LayoutKind.Sequential)]
public struct OLECMD
{
public uint cmdID;
public uint cmdf;
}
// Interop definition for IOleCommandTarget.
[System.Runtime.InteropServices.ComImport, Guid("b722bccb-4e68-101b-a2bc-00aa00404770"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IOleCommandTarget
{
void QueryStatus(ref Guid pguidCmdGroup, UInt32 cCmds, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] OLECMD[] prgCmds, ref OLECMDTEXT CmdText);
void Exec(ref Guid pguidCmdGroup, uint nCmdId, uint nCmdExecOpt, ref object pvaIn, ref object pvaOut);
}
//Disable URL DETECT ON WEBBROWSER
var CGID_MSHTML = new Guid("de4ba900-59ca-11cf-9592-444553540000");
var IDM_AUTOURLDETECT_MODE = (uint)2400;
var commandTarget = (IOleCommandTarget)webBrowser2.Document.DomDocument;
var arg1 = (object)false;
var arg2 = new Object();
commandTarget.Exec(ref CGID_MSHTML, IDM_AUTOURLDETECT_MODE, 0, ref arg1, ref arg2);