摘要: vs2010 rdlc .net4.0 卸载 Appdomain 时出错。 (异常来自 HRESULT:0x80131015) 解决办法 只要在窗口的关闭事件中,调用ReportViewer控件的LocalReport.Dispose()方法即可! 阅读全文
posted @ 2011-08-10 13:24 kenter 阅读(776) 评论(0) 推荐(0) 编辑
摘要: 1) 不要在线程函数体内操作MFC控件,不要再线程里面调用UpdateData函数更新用户界面,而应该尽量采用发送消息的方式,在主线程的消息响应函数中操作控件;2)不建议采用SendMessage往主线程发送消息,因为它是同步的,阻塞的,可以考虑采用PostMessage代替;3)线程退出时,尽量不要使用TerminateThread函数,而尽可能的让线程自己退出;4) 当线程退出时,必须先等待工作者线程退出,主线程才退出,但是在主线程里面不要使用WaitForSingleObject或 WaitForMultiObjects等待线程结束,因为它可能造成死锁,当主线程使用这两个函数时,主线程就 阅读全文
posted @ 2011-08-09 17:46 kenter 阅读(253) 评论(0) 推荐(0) 编辑
摘要: #include<time.h>#defineBEGIN_COUNT(mark)__int64__begin_count##mark;\QueryPerformanceCounter((LARGE_INTEGER*)&__begin_count##mark);\#defineEND_COUNT(mark)__int64__end_count##mark;\QueryPerformanceCounter((LARGE_INTEGER*)&__end_count##mark);\__int64__Frequency##mark;\QueryPerformanceFreq 阅读全文
posted @ 2011-08-08 09:08 kenter 阅读(266) 评论(1) 推荐(0) 编辑
摘要: [DllImport("winmm.DLL", EntryPoint = "PlaySound", SetLastError = true, CharSet = CharSet.Unicode, ThrowOnUnmappableChar = true)] private static extern bool PlaySound(string szSound, System.IntPtr hMod, PlaySoundFlags flags); [System.Flags] public enum PlaySoundFlags : int { SND_S 阅读全文
posted @ 2011-08-06 22:13 kenter 阅读(1823) 评论(1) 推荐(0) 编辑
摘要: #defineSINGLETON_CLASS_NO_DEF_CONSTRUCT_BODY(class_name)\private:\class_name();\class_name(constclass_name&);\class_name&operator=(constclass_name&);\public:\staticclass_name&Instance()\{\staticclass_nameone;\returnone;\}#defineSINGLETON_CLASS(class_name)\private:\class_name(){}\clas 阅读全文
posted @ 2011-08-01 23:40 kenter 阅读(257) 评论(0) 推荐(0) 编辑
摘要: [DllImport("user32.dll")]staticexternIntPtrSetParent(IntPtrhWndChild,IntPtrhWndNewParent);[DllImport("user32.dll")]privatestaticexternboolShowWindowAsync(IntPtrhWnd,intnCmdShow);privatevoidbutton1_Click(objectsender,EventArgse){System.Diagnostics.Processp=System.Diagnostics.Proce 阅读全文
posted @ 2011-07-31 23:11 kenter 阅读(262) 评论(0) 推荐(0) 编辑
摘要: privatevoidRotateTransform_Click(objectsender,System.EventArgse){Graphicsgraphics=this.CreateGraphics();graphics.Clear(Color.White);//装入图片Bitmapimage=newBitmap("nemo.bmp");//获取当前窗口的中心点Rectanglerect=newRectangle(0,0,this.ClientSize.Width,this.ClientSize.Height);PointFcenter=newPointF(rect.W 阅读全文
posted @ 2011-07-31 20:05 kenter 阅读(274) 评论(0) 推荐(0) 编辑
摘要: 大家都知道,在窗体上画图形,并显示出来很容易,只要得到相关容器的Graphics,就可以按照自己想要的样式去画;但是在WEB中,想要在某个页面中去随意画出图形并且显示出来则不能像窗体程序那样,因为不能获得某个容器的Graphics,这是B/S的架构有关,毕竟显示的页面是在Client,而你的处理地方是在Server端。那么如何在WEB程序中如何画图并显示,则需要一定设置,大致步骤如下:首先,需要设置WEB程序运行的目录下,设置一个临时目录,用于存放临时的图片文件,例如:“ImagesTemp”,并设置ASPNET用户能对此目录可写。接下来,画图的思路,是动态生成一个Bitmap,用它产生容器, 阅读全文
posted @ 2011-07-31 20:03 kenter 阅读(679) 评论(0) 推荐(0) 编辑
摘要: 要映射一个网络目录为本地驱动器,需要调用系统DLL的WNetAddConnection2函数来进行添加。首先,系统函数的申明如下:using System.Runtime.InteropServices; [DllImport("mpr.dll", EntryPoint="WNetAddConnection2")] public static extern uint WNetAddConnection2( [In] NETRESOURCE lpNetResource,string lpPassword,string lpUsername,uint dwF 阅读全文
posted @ 2011-07-31 19:59 kenter 阅读(1126) 评论(0) 推荐(0) 编辑
摘要: 很多人都疑惑,如何在窗体以外的地方绘制图像,其实在以前VC中很方便。其实在C#中也很方便,需要调用DLL的方法,大致如下。首先,定义DLL的函数,代码如下: [DllImport("User32.dll")] public extern static IntPtr GetDC(System.IntPtr hWnd); 然后就是调用了,如下代码是调用以上的方法画一个填充矩形: IntPtr DesktopHandle = GetDC(IntPtr.Zero); Graphics g = System.Drawing.Graphics.FromHdc(DesktopHandle 阅读全文
posted @ 2011-07-31 19:56 kenter 阅读(456) 评论(2) 推荐(2) 编辑