标签: dcef3使用方法

delphi中如何设置dcef3的代理服务器setproxy?

代理服务器(Proxy Server)是一种重要的服务器安全功能,它的工作主要在开放系统互联(OSI)模型的会话层,从而起到防火墙的作用。代理服务器大多被用来连接INTERNET(国际互联网)和Local Area Network(局域网)。delphi中的tChromium控件dcef3如何设置代理服务器呢? delphi中webbrowser设置代理服务器是这样的!1234567891011121314151617{------------------------------------------------------------------------------- 过程名: SetProcessProxy 作者: kelei 日期: 2013.08.03 参数: aProxyServer代理服务器; aProxyPort代理服务器端口 返回值: True设置成功 SetProcessProxy('127.0.0.1', 80);-------------------------------------------------------------------------------}function SetProcessProxy(const aProxyServer: string; const aProxyPort: Integer): Boolean;var vProxyInfo: TInternetProxyInfo;begin vProxyInfo.dwAccessType := INTERNET_OPEN_TYPE_PROXY; vProxyInfo.lpszProxy := PChar(Format('http=%s:%d', [aProxyServer, aProxyPort])); vProxyInfo.lpszProxyBypass := PChar(''); Result := UrlMkSetSessionOption(INTERNET_OPTION_PROXY, @vProxyInfo, SizeOf(vProxyInfo, 0) = S_OK;end; 在dcef3中如何静态设置代理服务器呢?静态设置方法在dpr中添加启动命令行参数,如果不添加命令行参数设置代理服务器,那么dcef3默认是使用的ie的代理服务器:123456789101112131415161718192021222324procedure AppendCefCmdline(const processType: ustring; const cmd: ICefCommandLine);begin cmd.AppendSwitchWithValue('proxy-server','http://218.189.26.20:8080');//设置http代理服务器 cmd.AppendSwitchWithValue('proxy-server','https://218.189.26.20:8082');//设置https代理服务器 cmd.AppendSwitchWithValue('proxy-server','ftp://218.189.26.20:21');//设置ftp代理服务器 cmd.AppendSwitchWithValue('proxy-server','socks://202.116.0.188:3128')//设置SOCKS代理服务器 cmd.AppendSwitchWithValue('proxy-server','sock4://202.116.0.188:1080')//设置sock4代理服务器 cmd.AppendSwitchWithValue('proxy-server','sock5://202.116.0.188:1081')//设置sock5代理服务器//cmd.AppendSwitchWithValue('proxy-server','direct://')//所有连接不使用代理//cmd.AppendSwitchWithValue('proxy-server','https=127.0.0.1:80;http=socks4://bnwin.com:1080')//同时设置https和sock4代理服务器 cmd.AppendSwitchWithValue('proxy-bypass-list','127.*,192.168.*,10.10.*,193.9.162.*');//不使用代理服务器的地址//cmd.AppendSwitch('--no-proxy-server');//禁止代理服务器//cmd.AppendSwitch('--proxy-auto-detect');//自动检测代理配置//cmd.AppendSwitchWithValue('proxy-pac-url','http://www.bnwinn.com/proxy.pac')//代理使用指定URL中的PAC文件//cmd.AppendSwitch('--winhttp-proxy-resolver');//代理在IE中运行正常,但在chrome中失败,可以添加此flagend; begin CefOnBeforeCommandLineProcessing :=AppendCefCmdline; //指定dcef启动命令行 Application.Initialize; Application.MainFormOnTaskbar := True; Application.CreateForm(TMainForm, MainForm); Application.Run;end. 在dcef3中如何动态设置代理服务器setproxy?前面已经说过,如果不在命令行中设置代理服务器,那么dcef是默认使用的ie代理服务器,要想动态设置代理服务器,我们不在dcef的命令行参数设置代理,然后使用开头的动态设置ie代理服务器的代码,dcef3的代理服务器就是动态的了! 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556System network settingsThe Chromium network stack uses the system network settings so that users and administrators can control the network settings of all applications easily. The network settings include:proxy settingsSSL/TLS settingscertificate revocation check settingscertificate and private key storesSo far this design decision has worked well. The only network settings that some users ask for an alternative to system settings are proxy settings. For this we recently added some command-line options that allow you to run Chromium with custom proxy settings.Preference service for network settingsAlthough the system network settings have been sufficient for our network stack, eventually there will be some configuration settings specific to our network stack, so we need to have our own preference service for those settings. See also issue 266, in which some Firefox users demand that we not use the WinInet proxy settings (the de facto system proxy settings on Windows).Command-line options for proxy settingsChrome supports the following proxy-related command line arguments:–no-proxy-serverThis tells Chrome not to use a Proxy. It overrides any other proxy settings provided.–proxy-auto-detectThis tells Chrome to try and automatically detect your proxy configuration. This flag is ignored if –proxy-server is also provided.–proxy-server==[:][;…] | [:] | “direct://”This tells Chrome to use a custom proxy configuration. You can specify a custom proxy configuration in three ways:1) By providing a semi-colon-separated mapping of list scheme to url/port pairs.For example, you can specify:–proxy-server=”http=foopy:80;ftp=foopy2″to use HTTP proxy “foopy:80” for http URLs and HTTP proxy “foopy2:80″ for ftp URLs.2) By providing a single uri with optional port to use for all URLs.For example:–proxy-server=”foopy:8080”will use the proxy at foopy:8080 for all traffic.3) By using the special “direct://” value.–proxy-server=”direct://” will cause all connections to not use a proxy.–proxy-bypass-list=(|)[:][;…]This tells chrome to bypass any specified proxy for the given semi-colon-separated list of hosts. This flag must be used (or rather, only has an effect) in tandem with –proxy-server.Note that trailing-domain matching doesn’t require “.” separators so “*google.com” will match “igoogle.com” for example.For example,–proxy-server=”foopy:8080″ –proxy-bypass-list=”*.google.com;*foo.com;127.0.0.1:8080″will use the proxy server “foopy” on port 8080 for all hosts except those pointing to *.google.com, those pointing to *foo.com and those pointing to localhost on port 8080.igoogle.com requests would still be proxied. ifoo.com requests would not be proxied since *foo, not *.foo was specified.–proxy-pac-url=This tells Chrome to use the PAC file at the specified URL.For example,–proxy-pac-url=”http://wpad/windows.pac”will tell Chrome to resolve proxy information for URL requests using the windows.pac file.

delphi中如何自定义dcef3的右键菜单?

delphi中TChromium控件dcef3的右键菜单默认是这样的如何修改成自己的菜单呢?或者自定义dcef3的右键菜单呢? 在dcef3窗体中添加TApplicationEvents控件aplctnvnts1! 添加TPopupMenu控件pm1,并设置好自定义的dcef3的右键菜单及功能. 在TApplicationEvents控件的OnMessage事件中添加如下代码。1234567891011procedure TMainForm.aplctnvnts1Message(var Msg: tagMSG; var Handled: Boolean);var mPoint: TPoint;begin if IsChild(chrm1.Handle, Msg.Hwnd) and ((Msg.Message = WM_RBUTTONDOWN) or (Msg.Message = WM_RBUTTONUP)) then begin GetCursorPos(mPoint); //得到光标位置 pm1.Popup(mPoint.X, mPoint.Y); //弹出popupmenu的菜单 Handled := True; end;end; 这样你就不用让用户看TChromium的默认英文右键菜单了!对于TChromium默认右键菜单的功能,可以自己用代码很轻松的实现!

delphi中如何删除dcef3的cookie和缓存?

我们用以下代码打开网站 12345678910var Chromium: TChromium;begin try Chromium := TChromium.Create(nil); Chromium.SetParentComponent(Form1); Chromium.Align := alClient; chromium.Browser.MainFrame.LoadUrl('www.bnwin.com'); FreeAndNil(Chromium)end; 如何删除dcef3的cookie和缓存?请看以下代码 123456789101112131415161718192021222324252627282930313233343536373839type CefTask = class(TCefTaskOwn) procedure Execute; override; public var url,cookieName: ustring; constructor create; virtual; end; constructor CefTask.create;begin inherited create; url := ''; cookieName := '';end; procedure CefTask.Execute;var CookieManager: ICefCookieManager;begin CookieManager := TCefCookieManagerRef.Global; CookieManager.DeleteCookies(url,cookieName);end; procedure c_WB_ClearCookies;var Task: CefTask;begin Task := CefTask.Create; CefPostTask(TID_IO, Task);end; // c_WB_Clear_url_Cookies('http://google.com','cookie_name');procedure c_WB_Clear_url_Cookies(c_url,c_cookieName: ustring);var Task: CefTask;begin Task := CefTask.Create; Task.url := c_url; Task.cookieName := c_cookieName; CefPostTask(TID_IO, Task);end; 整理自网站 https://stackoverflow.com/questions/12269587/how-do-i-clear-the-cache-and-cookies-for-an-embedded-chromium-browser 取得cookie并显示,如果需要删除cookie,把deleteCookie:= False改为deleteCookie:= True 123456789101112131415161718192021222324252627282930313233343536373839404142434445function VisitCookie (const name, value, domain, path: ustring; secure, httponly, hasExpires: Boolean;const creation, lastAccess, expires: TDateTime; count, total: Integer;out deleteCookie: Boolean): Boolean;begin deleteCookie:= False; MainForm.Memo1.Lines. Add (' cookie ' +inttostr (count) + ' / ' + inttostr (total)); MainForm.Memo1.Lines. Add (' name ' +name); MainForm.Memo1.Lines. Add (' value ' +value); MainForm.Memo1.Lines. Add (' domain ' +domain); MainForm.Memo1.Lines. Add (' path ' +path); MainForm.Memo1.Lines. Add (' secure ' +BoolToStr (secure)); MainForm.Memo1.Lines. Add (' httponly ' +BoolToStr (httponly)); MainForm.Memo1.Lines. Add (' hasExpires ' +BoolToStr (hasExpires)); MainForm.Memo1.Lines. Add (' creation ' +DateToStr (creation)); MainForm.Memo1.Lines. Add (' lastAccess ' +DateToStr (lastAccess)); MainForm.Memo1.Lines. Add (' expires ' +DateToStr (expires)); MainForm.Memo1.Lines. Add ('--------------- '); Result:= True;end; procedure TMainForm.btn2Click(Sender: TObject);var CookieManager: ICefCookieManager;beginCookieManager:= TCefCookieManagerRef.Global(nil);CookieManager.VisitAllCookiesProc (VisitCookie);end; //这样写,我在delphi xe8中编译不过procedure TMainForm.Button1Click(Sender: TObject);var CookieManager: ICefCookieManager;begin CookieManager := TCefCookieManagerRef.Global(nil); CookieManager.VisitAllCookiesProc( function(const name, value, domain, path: ustring; secure, httponly, hasExpires: Boolean; const creation, lastAccess, expires: TDateTime; count, total: Integer; out deleteCookie: Boolean): Boolean begin deleteCookie := True; ShowMessage('A cookie from domain ' + domain + ' will be unmercifully ' + 'deleted!'); end );end; 为网址设置单独的cookie文件 1234567891011121314CookieManager: ICefCookieManager; FormCreate:begin CookiesPath := ExtractFilePath(Application.ExeName) + 'cookies/bnwin'; CookieManager := TCefCookieManagerRef.Global(nil); CookieManager.SetStoragePath(CookiesPath, True, nil); Chromium1.Load('bnwin.com'); end; FormClose: begin CookieManager.FlushStore(nil);end 为指定的网站设置cookie

delphi中dcef如何自定义referer信息?

TChromium自定义referer,在早期的dcef版本中,这样Append(‘Referer’,’http://www.bnwin.com’)就可以了,详细看下面代码,如果append不行,启用这句request.SetReferrer(request.url, REFERRER_POLICY_ALWAYS); 123456789101112131415161718192021procedure TMainForm.chrm1BeforeResourceLoad(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const request: ICefRequest; const callback: ICefRequestCallback; out Result: TCefReturnValue);var map: ICefStringMultimap; sAccept,sUserAgent:string;begin sAccept:= 'application/x-shockwave-flash, image/gif, image/jpeg, image/pjpeg, application/x-ms-application, application/x-ms-xbap,'+ ' application/vnd.ms-xpsdocument, application/xaml+xml,text/html,application/octet-stream, */*'; sUserAgent:='Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36 QIHU 360EE'; map := TCefStringMultimapOwn.Create; request.GetHeaderMap(map); map.Append('Referer',request.url); map.Append('Accept',sAccept); map.Append('User-Agent',sUserAgent); // ShowMessage(map.getvalue(1)+' '+map.getkey(1)); request.SetHeaderMap(map); //map:=nil; //request.SetReferrer(request.url, REFERRER_POLICY_ALWAYS);end; 在高版本的dcef中自定义referer,可以直接定义request. 12345678910111213141516171819procedure TMainForm.ShowUrl(hurl,AllUrl:string);var Request: ICefRequest; Data: ICefPostData; Header: ICefStringMultimap; sUserAgent:string;begin if chrm1.Browser.IsLoading then chrm1.Browser.StopLoad; sUserAgent:='Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36 QIHU 360EE'; Request := TCefRequestRef.New; Request.SetReferrer(hurl,REFERRER_POLICY_ORIGIN);//定义referer Data := TCefPostDataRef.New; Header := TCefStringMultimapOwn.Create; Header.Append('Accept-Language', 'zh-CN'); Header.Append('User-Agent',sUserAgent); Request.Assign(AllUrl,'POST',Data,header); chrm1.Browser.MainFrame.LoadRequest(Request);end;

delphi中如何让dcef支持flash插件播放视频?

Chromium Embedded Framework (CEF)是个基于Google Chromium项目的开源Web browser控件,支持Windows, Linux, Mac平台。除了提供C/C++接口外,也有其他语言的移植版。因为基于Chromium,所以CEF支持Webkit & Chrome中实现的HTML5的特性,并且在性能上面,也比较接近Chrome。CEF还提供的如下特性:自定义插件、自定义协议、自定义JavaScript对象和扩展;可控制的resource loading, navigation, context menus等等。dcef是指的cef在delphi中的版本 cef在前期版本中是自带支持flash插件的,后来Chromium不再默认支持flash控件!下面看看我的程序的dcef命令行参数 如何让dcef支持flash呢? 安装好dcef,不管哪个版本都行! 安装360极速浏览器或QQ浏览器,打开其安装目录,找到ppflash目录和npflash目录(360极速浏览器是这两个目录,而QQ浏览器略有不同)! 在你的工程目录中建NativeFlash目录和PepperFlash目录,然后360的npflash目录下的NPSWF开头的dll文件和同目录下的vch文件复制到自己工程的NativeFlash中,把360的ppflash目录中的pepflash开头的dll文件和同目录下的json文件复制到工程的PepperFlash目录中!这一步就是用360浏览器的flash文件,不需要你手工去下载安装插件!至少你应该发现即使你的系统没有安装flash插件,但360浏览器安装后一样可以正常播放flash,这就是因为他的目录中自带了这几个flash文件,为了让你的程序的dcef支持flash,所以我们直接复制360极速浏览器的flash文件过来,简单方便! 编辑你的delphi工程文件(即dpr文件),在{$R *.res}后面添加如下代码123456789101112131415161718192021procedure AppendCefCmdline(const processType: ustring; const cmd: ICefCommandLine);begin //cmd.AppendSwitch('--enable-gpu-plugin');//允许gpu //cmd.AppendSwitch('disable-gpu');//禁止gpu cmd.AppendSwitch('enable-npapi'); //允许NativeFlash //cmd.AppendSwitch('enable-tab-audio-muting');//允许tab页禁音 //cmd.AppendSwitch('--enable-media-stream'); //允许视频流 cmd.AppendSwitchwithvalue('load-plugin', 'NativeFlash\NPSWF32.dll');//指定NativeFlash插件文件位置,注意文件名要和你的一致 //cmd.AppendSwitchWithValue('ppapi-flash-version','20.0.0.267');//指定PepperFlash版本号 cmd.AppendSwitchWithValue('ppapi-flash-path','PepperFlash\pepflashplayer.dll');//指定PepperFlash插件文件位置,注意文件名要和你的一致 cmd.AppendSwitch('--enable-system-flash');//允许PepperFlash //cmd.AppendSwitch('--enable-usermedia-screen-capturing');end; begin CefOnBeforeCommandLineProcessing :=AppendCefCmdline; //这一句就是指定了dcef启动的命令行 Application.Initialize; Application.MainFormOnTaskbar := True; Application.CreateForm(TMainForm, MainForm); Application.Run;end. 很多人用delphi的dcef写的程序,不支持flash,是只在命令行中添加了允许flash,而没有指定flash插件文件的位置,这时dcef会去调用系统安装的flash插件,一旦系统插件有问题,你的程序就无法播放flash了,本文写的方法就是360极速浏览器的方法,不管你的系统安装不安装flash,一样播放flash!而要让dcefbrowser支持flash也一样,dcefbrowser中只是把CefOnBeforeCommandLineProcessing改为DcefBApp.OnBeforeCommandLineProcessing即可,至于播放flash会有dos窗口弹一下的问题,请看本站的这篇文章http://www.bnwin.com/2017/12/01/328.html

dcef3加载flash闪烁问题简单解决方法

dcef3添加flash插件后,在播放flash时会有一个dos的黑框一闪而过,显示not sandboxed,影响使用体验! 一种方法是hook 具体可以看这篇文章 http://blog.csdn.net/zx2356/article/details/51514403这篇文章是使用的C语言,这儿采用同样的方法,在delphi中实现!代码如下HookExt.pas源码123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100unit HookExt; interfaceuses uhook,Windows,SysUtils; type TFuncCreateProcessA = function(lpApplicationName: LPCSTR; lpCommandLine: LPSTR; lpProcessAttributes, lpThreadAttributes: PSecurityAttributes; bInheritHandles: BOOL; dwCreationFlags: DWORD; lpEnvironment: Pointer; lpCurrentDirectory: LPCSTR; const lpStartupInfo: TStartupInfoA; var lpProcessInformation: TProcessInformation): BOOL; stdcall; TFuncCreateProcessW = function(lpApplicationName: LPCWSTR; lpCommandLine: LPWSTR; lpProcessAttributes, lpThreadAttributes: PSecurityAttributes; bInheritHandles: BOOL; dwCreationFlags: DWORD; lpEnvironment: Pointer; lpCurrentDirectory: LPCWSTR; const lpStartupInfo: TStartupInfoW; var lpProcessInformation: TProcessInformation): BOOL; stdcall; implementation var hhk: HHook; MapFile: THandle; startPID: PDWORD; Hook: array [0 .. 1] of TNtHookClass; function NewCreateProcessA(lpApplicationName: LPCSTR; lpCommandLine: LPSTR; lpProcessAttributes, lpThreadAttributes: PSecurityAttributes; bInheritHandles: BOOL; dwCreationFlags: DWORD; lpEnvironment: Pointer; lpCurrentDirectory: LPCSTR; const lpStartupInfo: TStartupInfoA; var lpProcessInformation: TProcessInformation): BOOL; stdcall;var strCommandLine: AnsiString;begin strCommandLine := StrPas(lpCommandLine); if (Pos('echo NOT SANDBOXED',strCommandLine)>0) or (Pos('no-sandbox',strCommandLine)>0) then Result := True else begin Hook[0].UnHook; Result := TFuncCreateProcessA(Hook[0].BaseAddr)(lpApplicationName, lpCommandLine, lpProcessAttributes, lpThreadAttributes, bInheritHandles, dwCreationFlags, lpEnvironment, lpCurrentDirectory, lpStartupInfo, lpProcessInformation); Hook[0].Hook; end;end; function NewCreateProcessW(lpApplicationName: LPCWSTR; lpCommandLine: LPWSTR; lpProcessAttributes, lpThreadAttributes: PSecurityAttributes; bInheritHandles: BOOL; dwCreationFlags: DWORD; lpEnvironment: Pointer; lpCurrentDirectory: LPCWSTR; const lpStartupInfo: TStartupInfoW; var lpProcessInformation: TProcessInformation): BOOL; stdcall;var strCommandLine: string;begin strCommandLine := StrPas(lpCommandLine); if (Pos('echo NOT SANDBOXED',strCommandLine)>0) or (Pos('no-sandbox',strCommandLine)>0) then Result := True else begin Hook[1].UnHook; Result := TFuncCreateProcessW(Hook[1].BaseAddr)(lpApplicationName, lpCommandLine, lpProcessAttributes, lpThreadAttributes, bInheritHandles, dwCreationFlags, lpEnvironment, lpCurrentDirectory, lpStartupInfo, lpProcessInformation); Hook[1].Hook; end;end; // 安装API Hookprocedure InitHook;begin Hook[0] := TNtHookClass.Create('kernel32.dll', 'CreateProcessA', @NewCreateProcessA); Hook[1] := TNtHookClass.Create('kernel32.dll', 'CreateProcessW', @NewCreateProcessW); // Hook[2] := TNtHookClass.Create( 'user32.dll', 'MessageBoxA', @NewMessageBoxA );end; // 删除API Hookprocedure UnInitHook;var i: Integer;begin for i := 0 to High(Hook) do FreeAndNil(Hook[i]);end; // 环境处理procedure DllEntry(dwReason: DWORD);begin case dwReason of DLL_PROCESS_ATTACH: InitHook; DLL_PROCESS_DETACH: UnInitHook; end;end; initialization InitHook; finalization UnInitHook;end. 其中的uHook.pas源码:12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788unit uHook; interface usesWindows, Messages, SysUtils;type TNtJmpCode = packed record MovEax: Byte; Addr: DWORD; JmpCode: Word; dwReserved: Byte; end; TNtHookClass = class(TObject) private hProcess: THandle; NewAddr: TNtJmpCode; OldAddr: array [0 .. 7] of Byte; ReadOk: Boolean; public BaseAddr: Pointer; constructor Create(const ADllName, AFuncName: string; ANewFunc: Pointer); destructor Destroy; override; procedure Hook; procedure UnHook; end; implementation { TNtHookClass } constructor TNtHookClass.Create(const ADllName, AFuncName: string; ANewFunc: Pointer);var dllModule: HMODULE; lpNumberOfBytesReacd: DWORD; //NativeUInt; i:Integer;begin // 获取模块句柄 dllModule := GetModuleHandle(PWideChar(ADllName)); if dllModule = 0 then dllModule := LoadLibrary(PWideChar(ADllName)); // 得到模块入口地址 BaseAddr := Pointer(GetProcAddress(dllModule, PWideChar(AFuncName))); // 获取当前进程句柄 hProcess := GetCurrentProcess; // 指向新地址的指针 NewAddr.MovEax := $B8; NewAddr.Addr := DWORD(ANewFunc); NewAddr.JmpCode := $E0FF; // 保存原始地址 ReadOk:=ReadProcessMemory(hProcess, BaseAddr, Pointer(@OldAddr), 8, lpNumberOfBytesReacd); // 开始拦截 Hook; end; destructor TNtHookClass.Destroy;begin UnHook; CloseHandle(hProcess); inherited;end; procedure TNtHookClass.Hook;var lpNumberOfBytesRead: DWORD;begin if not ReadOk then exit; // 写入新的地址 WriteProcessMemory(hProcess, BaseAddr, @NewAddr, 8, lpNumberOfBytesRead);end; procedure TNtHookClass.UnHook;var lpNumberOfBytesRead: DWORD;begin if not ReadOk then exit; // 恢复地址 WriteProcessMemory(hProcess, BaseAddr, @OldAddr, 8, lpNumberOfBytesRead); end; end. 这种hook处理不好就容易蓝屏,更简单的方法如下:用二进制编辑软件,比如winhex,我这儿采用UltraEdit,用UltraEdit打开flash插件dll文件 pepflashplayer.dll 搜索comspec修改为somspec,(修改的名字只要和comspec不相同即可)修改cmd.exe为cm1.exe (修改的名字只要和cmd.exe不相同即可) 修改后为 然后保存即可,这时打开flash就不会有dos黑框闪一下了! 第三种方法,更简单,什么都不用修改,只要在你的程序目录下新建一个文本文件,然后改名为cmd.exe,因为弹出黑框需要使用cmd程序,而系统搜索程序是从进程当前的工作目录开始查找,所以直接这样建一个不能执行的cmd.exe文件可以拦截cmd的调用。这个方法最简单! 第一种hook方法是修改flash文件,但其实是采用动态方法改了汇编代码,处理不好容易蓝屏。第二种方法修改flash插件文件,原理是:flash执行cmd的逻辑是,先读取环境变量comspec(cmd.exe的全路径),读取到就执行它,读取不到就不执行cmd.exe.只要把变量和cmd.exe名字修改,就执行不成功,就没有DOS黑框出来!第一种方法是在flash插件要运行cmd.exe的时候再进行拦截,是动态修改的,而第二种是直接让flash找不到变量和cmd.exe程序,flash自己判断不用执行,是静态修改!第三种是懒人方法!但几种方法实现的效果都是阻止cmd.exe的正常执行!同时你就可以这样思考了,为了让flash不出现闪黑框的问题,就变成了如何阻止cmd.exe的执行,比如你在你自己的程序中先修改一下comspec环境变量,也是可以阻止cmd.exe执行的,大家自由发挥!

如何自定义修改TChromium的header头信息!

TChromium自定义post的header信息提交数据1234567891011121314151617181920212223242526272829uses ceflib; function CreateField(const AValue: AnsiString): ICefPostDataElement;begin Result := TCefPostDataElementRef.New; Result.SetToBytes(Length(AValue), PAnsiChar(AValue));end; procedure TForm1.Button1Click(Sender: TObject);var Header: ICefStringMultimap; Data: ICefPostData; Request: ICefRequest;begin Header := TCefStringMultimapOwn.Create; Header.Append('Content-Type', 'application/x-www-form-urlencoded'); Data := TCefPostDataRef.New; Data.AddElement(CreateField('Data.id=27')); Data.AddElement(CreateField('&Data.title=title')); Data.AddElement(CreateField('&Data.body=body')); Request := TCefRequestRef.New; Request.Flags := WUR_FLAG_NONE; Request.Assign('http://example.com/', 'POST', Data, Header); Chromium1.Browser.MainFrame.LoadRequest(Request);end; 在另一版本中的代码1234567891011121314151617181920212223procedure TForm1.Button1Click(Sender: TObject);var Header: ICefStringMultimap; Data: ICefPostData; Request: ICefRequest;begin Request := TCefRequestRef.New; Request.Url := 'http://example.com/'; Request.Method := 'POST'; Request.Flags := WUR_FLAG_NONE; Header := TCefStringMultimapOwn.Create; Header.Append('Content-Type', 'application/x-www-form-urlencoded'); Request.SetHeaderMap(Header); Data := TCefPostDataRef.New; Data.AddElement(CreateField('Data.id=27')); Data.AddElement(CreateField('&Data.title=title')); Data.AddElement(CreateField('&Data.body=body')); Request.PostData := Data; Chromium1.Browser.MainFrame.LoadRequest(Request);end; TChromium自定义post数据123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051function CreateField(const AValue: AnsiString): ICefPostDataElement;begin Result := TCefPostDataElementRef.New; Result.SetToBytes(Length(AValue), PAnsiChar(AValue));end; //***************************************** procedure POST(total, fee: integer);var Header: ICefStringMultimap; Data: ICefPostData; Request: ICefRequest; Cook: ICefCookieManager;begin Request := TCefRequestRef.New; Request.Url := ''; Request.Method := 'POST'; Request.Flags:=[UR_FLAG_ALLOW_CACHED_CREDENTIALS,UR_FLAG_ALLOW_COOKIES]; Header := TCefStringMultimapOwn.Create; Header.Append('Host', ''); Header.Append('User-Agent', ''); Header.Append('Accept', ''); Header.Append('Accept-Language', ''); Header.Append('Accept-Encoding', ''); Header.Append('Content-Type', ''); Header.Append('Referer', ''); Header.Append('Content-Length', ''); Header.Append('Origin', ''); Header.Append('Connection', ''); Header.Append('Pragma', ''); Header.Append('Cache-Control', ''); Header.Append('Cookie','...'); ... Header.Append('Cookie','...'); Request.SetHeaderMap(Header); Data := TCefPostDataRef.New; Data.AddElement(CreateField('sessionid='+SessionID)); Data.AddElement(CreateField('¤cy=5')); Data.AddElement(CreateField('&subtotal='+inttostr(total-fee))); Data.AddElement(CreateField('&fee='+IntToStr(fee))); Data.AddElement(CreateField('&total='+IntToStr(total))); Request.PostData := Data; form1.Chromium1.Browser.MainFrame.LoadRequest(Request);end;

如何让dcef3支持mp3和h.264_mp4解码播放(有源码及dll)!

嵌入式Chromium框架(简称CEF) 是一个由Marshall Greenblatt在2008建立的开源项目,它主要目的是开发一个基于Google Chromium的Webbrowser控件。CEF支持一系列的编程语言和操作系统,并且能很容易地整合到新的或已有的工程中去。它的设计思想政治就是易用且兼顾性能。CEF基本的框架包含C/C++程序接口,通过本地库的接口来实现,而这个库则会隔离宿主程序和Chromium&Webkit的操作细节。它在浏览器控件和宿主程序之间提供紧密的整合,它支持用户插件,协议,javascript对象以及javascript扩展,宿主程序可以随意地控件资源下载,导航,下下文内容和打印等,并且可以跟Google Chrome浏览器一起,支持高性能和Html5 技术 为什么chromium不支持mp3和h.264的mp4音视频解码,因为h.264编码并非开源,是需要付费的!所以就存在谷歌自己的浏览器chrome能支持mp4和tchromium不支持mp4!如何查看你的tchromium是否支持mp4呢?你用tchromium写一个简单浏览器,然后打开http://html5test.com 支持是这样显示的 而不支持是这样显示的 也就是支持h.264 support mp3 support和aac support应该是钩! 要让cef支持mp3和mp4,需要自己编译,如果你对自己如何编辑有兴趣可以看这篇文件 在Windows下编译Cef3.2623并加入mp3、mp4支持 对于delphi用户,如何让在delphi中dcef3支持mp3和mp4呢?先到这儿下载dcef3 3.2623.1401 http://download.csdn.net/download/cyu/9917747 (如果没有积分就到这儿下载 链接:https://pan.baidu.com/s/1dFETI0L 密码:gult ) 你也可以安装dcefbrowser,封装后的dcef3 这儿下载dcefbrowser3.2623.1401 https://github.com/bccsafe/DcefBrowser (你也可以到这儿下载dcefbrowser 链接:https://pan.baidu.com/s/1dFB5Zv7 密码:fljs )不管你是下载的dcef3 3.2623.1401 还是下载的dcefbrowser 3.2623.1401都可以,安装控件后,运行示例程序,这时你的dcef是不支持mp3和mp4的,为什么呢?因为h.264等编码问题,作者打包的dll库文件是默认不支持mp3和mp4的! 如何让delphi中dcef3支持mp3和mp4呢?你只需要到这儿下载 链接:https://pan.baidu.com/s/1c1DZ1DY 密码:sqir 已经编译好支持mp3和mp4的dll库,覆盖到前面安装的控件中,就OK了,因为这个dll库是对应于dcef3.2623.1401,所以dcef必须也要安装3.26.23.1401。如何让delphi中dcef3支持mp3和mp4呢?因为非开源问题,所以自己编译dcef3的dll库的不多,提供下载的也不多,为了让你的dcef3支持mp3和mp4,我们只要找对应的版本就可以使用了!为什么非要指定dcef3为3.2623.1401,这是因为编译cef的dll需要开启mp3和mp4支持,网上提供其他版本的cef的dll库,并且加入了支持mp3和mp4的没有,如果你会C++,会自己编译cef的库,那什么版本都一样,都可以支持mp3和mp4 附dcef3另一版本及库文件:dcef3.2454 下载http://download.csdn.net/download/bigcoolfish/9616325 相对应已添加支持mp3和mp4的 dcef3.2454 dll库文件下载 https://pan.baidu.com/s/1pKHbeY3 密码: mxr2