琐碎知识点

mac2022-06-30  21

 13、反射获取方法所在的类名称:System.Reflection.MethodBase.GetCurrentMethod().DeclaringType

12、try{}catch(){}finally{//必定进入}

try { throw new Exception("try"); } catch(Exception ex) { Debug.Write(ex.Message);//进入 throw new Exception("catch");//进入 } finally { Debug.Write("finally");//必定进入 } View Code

11、 ConfigurationManager.AppSettings["SQLiteConnectionString"];加载的是 启动工程下的配置文件而不是代码所在工程的配置文件

<appSettings> <add key="SQLiteConnectionString" value="Data Source=framework.db3;Pooling=true;FailIfMissing=false"/> </appSettings> View Code

10、System.Environment.ProcessorCount  //获取当前计算机上的处理器数。

 9、 System.Threading.Tasks.Task.Factory.StartNew(new Action(Func) );  //Action要异步执行的操作委托。

 8、设置Form样式:

SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor, true); this.UpdateStyles(); SetClassLong(this.Handle, GCL_STYLE, GetClassLong(this.Handle, GCL_STYLE) | CS_DropSHADOW); View Code

 7、探照灯实现: 一个全屏幕布,在幕布上打个孔(圆形|方形。。。),空后面显示一个窗体,窗体的大小是空的大小,显示的内容是屏幕方孔位置的图片。

  注意点:1、高分别率下:拷贝图片大小要依据分辨率参数/97比例变化 2、依靠具体GraphicsPath : Region rgn = new Region(rec); rgn.Exclude(GraphicsPath );3、添加边框、工具主要是逻辑坐标、放大缩小等

 6、FFMpeg:给ffmpeg.exe输入命令实现录制屏幕

Process p = new Process();/ p.StartInfo.FileName = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, @"FFmpeg\ffmpeg.exe"); p.StartInfo.Arguments = @"-f dshow -i video=""screen-capture-recorder"" -r 5 -vcodec libx264 -pix_fmt yuv420p -preset:v ultrafast -tune:v zerolatency MyDesktop8891.mp4"; View Code

 

 5、Ftp上传下载:以流的形式建立通道,接受数据(下载)、发送数据(上传)。

FtpWebRequest\FtpWebResponse\NetworkCredential\FtpStatusCode

上传:(FtpWebRequest)FtpWebRequest.Create(new Uri(url));

  Stream strm = FtpWebRequest.GetRequestStream();

  strm.Write(buff, 0, contentLen); 

下载: FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();            Stream ftpStream = response.GetResponseStream(); 

    FileStream outputStream = new FileStream(filename, FileMode.Create); 

    outputStream.Write(buffer, 0, readCount);  

4、程序播放Windows系统声音:Media.SoundPlay(资源.铃声)

3、防火墙: netsh advfirewall set allprofiles off | on  程序中可做为cmd命令,从而操作防火墙

2、二维图:ZXing.dll  、 ThoughtWorks.dll  (.QRcode.codec)

1、Windows系统 Pad远程桌面:运行=>mstsc;输入msconfig命令,在工具项中查看更多功能命令

转载于:https://www.cnblogs.com/shenchao/p/6419732.html

最新回复(0)