Tag: C#
-
Howto: Ignoring web browser certificate errors in a webbrowser host
The webbrowser queries host services via IServiceProvider implemented on the ActiveX host. One of the services is IHttpSecurity, which can be used to override the certificate problem dialog. Security warning: ignoring security problems can compromise your application. IHttpSecurity is derived from IWindowForBindingUI, so the host needs to implement it too. In Windows forms, customizing certificate error handling…
-
What is the difference between int and System::Int32
Some may say identical, at least that’s what the Visual C++ compiler tells you at the first glance when you turn on /oldsyntax public __gc class Class1 { public: void F1(int a){} void F1(System::Int32 a){} //Error 2 error 2535: void Class1::F1(int)’ : member function already defined or declared } Okay, so if I add & to…
-
Make the webbrowser control styled the same way as the hosting application
User wtx_sonery wants to know whether it is possible to style the webbrowser control with the rest of the application. The answer is yes, you can implement IDocHostUIHandler’s GetHostInfo method and return DOCHOSTUIFLAG_THEME in the host flags. IDocHostUIHandler is already implemented in MFC and ATL. For MFC there are CHtmlControlSite and CBrowserControlSite but you should…
-
Detect if a MSI component is installed
A C# program for those who don’t know MSI SDK or C++. C++ programmers can find the API inside the msi.h file in Windows SDK. class Program { static int Main(string[] args) { uint pathSize = 0; try { foreach (string componentId in args) { MsiInstallState state = MsiLocateComponent( componentId, null, ref pathSize); if (state…
-
MFC更新Beta版
一个面向Visual C++ 2008的MFC更新测试版已经发布,同时也提供了文档的下载。这个版本包含新的界面的特性,例如Office Ribbon、2003和XP风格,Visual Studio风格和MDI标签。另外,这个版本也包含部分TR1的实现,例如正则表达式、更加丰富的集合和智能指针。 另外,在下载页面居然说这个版本还不支持Visual Studio 2008 Service Pack 1的Beta版,正式版才出来几天SP1的测试版就出来了?
-
STL/CLR, Compiler and Marshaling
MSDN第9频道又采访了Visual C++类库组的项目经理Nikola Dudar和Sarita Bafna,以及质量控制组的Marina Polishchuk。尽管Visual C++项目组已经转移了工作重点,但是很少人注意到这一点。或许这些采访可以帮助你了解Visual C++项目组的工作。 为什么C++仍旧重要? 非托管的应用程序有很大的代码积累,而这些程序的升级工作仍旧在进行 性能是选择C++的重要因素。举例来说,游戏和杀毒程序更适合用非托管代码来编写。 多平台支持。虽然.Net号称是跨平台的,但是如果要编写真正的跨平台程序,开发的时候遵循C++标准还是很有必要的。 为什么C++程序员仍旧重要? C++程序员理解整个机器的运作,他们知道怎么写垃圾收集机制,甚至可以写机器代码 C++程序员可以很容易的学会其他语言——C++已经是最难学的语言之一了 C++程序员并不只使用一种语言。如果有必要的话,他们会选择汇编、C#或者Perl这样更适合特定任务的语言。 为什么Visual C++项目组转移了工作重点? C++程序员对于转到C#没有抵触心理,所以Visual C++项目组不认为有必要尽快实现Visual C#支持的所有特性,比如LINQ和WPF设计器 C++程序员对于让他们的非托管程序调用其他语言的托管代码比用C++来写托管代码更有兴趣 核心模块,例如IE和Windows外壳会更加频繁地更新,而会有更多的非托管代码需要调用这些新的特性,为了这些特性,有必要在MFC中引入新的封装类来节省C++程序员的时间 Orcas中Visual C++的新特性: 托管代码互操作库。可扩展的托管数据类型和非托管数据类型的转换支持 STL/CLR。使得托管代码可以利用旧的STL编写的算法 Vista支持。对Vista中新的通用控件和文件对话框等界面元素的MFC封装。 DevExpess重构引擎——将包含DevExpess的Refactor!™ for C++。 Orcas之后的考虑 更新界面。有些Visual C++的代码是针对20年之前的硬件环境设计的,已经不适合现在的需要。新的Phoenix编译引擎使得重写前台变得更加容易。 太多现有的代码需要重构。新的Phoenix编译引擎使得代码分析变得更加容易。 C++标准。新的C++标准TR1可能会在Orcas下一版本开发时成为正式标准。 多核支持。需要编写可以充分利用多CPU的代码。第一个尝试是LINQ。 结论 MFC和非托管代码回来了 性能和多平台支持的重要性越来越低,托管代码仍旧具有很大的市场。 Visual C++项目组的其他动作 ATL Server发布到了源代码共享站点CodePlex。这包含CAtlRegExp,在.Net和第三方类库(boost,TR1)的竞争下已经不再有必要维护一个单独的条件表达式标准了
-
Error: Unable to cast COM object of type ‘mshtml.HTMLDocumentClass’ to interface type ‘ICustomDoc’
This operation failed because the QueryInterface call on the COM component for the interface with IID ‘{3050F3F0-98B5-11CF-BB82-00AA00BDCE0B}’ failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)). My first reaction was:”What the hell? HTMLDocumentClass is the managed wrapper of MSHTML, and MSHTML is supposed to support the ICustomDoc interface!” Now…